''' Created on Apr 29, 2014 @author: bob ''' import random import re productions = { 'topics': [ 'Quantum Physics', 'morality', 'mortality', 'space exploration', 'continental philosophy', 'mathematics', 'chemistry', 'politics', 'biology', 'astronomy', 'geology', 'painting', 'Art', 'equality', 'computers', 'political utopia', 'architecture', 'community', 'using the Fibonacci sequence' ], 'other': [ 'bacon', 'bourbon', 'beer', 'jam bands', 'triathlon', 'cycling', 'ocd', 'anxiety', 'depression', 'lonliness', 'failure', 'career', 'self', 'comic books', 'cognitive behavioral therapy', 'body image', 'identity', 'self-worth', 'genealogy/ancestry', 'modernism', 'abstraction', 'art history', 'science fiction', 'One if by land, Two if by Sea', 'Mies van der Rohe (Jesus built my hot rod)', 'If you like Clyfford Still, you need your head examined', 'What would Douglas Adams do?' ], 'scale': [ 'quantum', 'atomic', 'molecular', 'chemical', 'cellular', 'body', 'family', 'home', 'neighborhood', 'urban', 'state', 'regional', 'national', 'global', 'solar', 'galactic', 'universal', ], 'title': [ 'The ${topics} of ${other}.', 'Comparison of ${topics} & ${topics} on a ${scale} scale.', 'exploration the ${topics} of ${other} on a ${scale} scale.', 'comparison of ${topics} with ${other}.', 'comparison of ${other} and ${other}.', '${other}.' ], } def randomly_generated(nt): template = random.choice(productions[nt]) def replace(match): return randomly_generated(match.group(1)) return re.sub(r'\$\{(\w+)\}', replace, template) randomly_generated('title')
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question