1👍
✅
If you’re willing to change the notation, you have two options:
-
>>> 'Starting in {Duration}, the {Noun} will be {Adjective}'.format(Duration='24 hours', Noun='Coffee Maker', Adjective='broken') 'Starting in 24 hours, the Coffee Maker will be broken' >>> 'Starting in %(Duration)s, the %(Noun)s will be %(Adjective)s' % dict(Duration='24 hours', Noun='Coffee Maker', Adjective='broken') 'Starting in 24 hours, the Coffee Maker will be broken'
-
>>> from django.template import Context, Template >>> t = Template('Starting in {{Duration}}, the {{Noun}} will be {{Adjective}}') >>> c = Context(dict(Duration='24 hours', Noun='Coffee Maker', Adjective='broken')) >>> t.render(c) u'Starting in 24 hours, the Coffee Maker will be broken'
The rest is pulling from the database and selecting the words at random, which is the easy part.
Source:stackexchange.com