I love Python because of things like random.choice, a usefulĀ little method that allows you to create mission-critical functionality with very little code. For example, who doesn’t need a random Kung Fu move name at least once a week? I know I do. With Python, its a snap.
[python]
>>> from random import choice
>>> a = [‘flying’, ‘thunderous’, ‘crushing’]
>>> b = [‘hammer’, ‘eagle’, ‘snake’, ‘dragon’, ‘lotus’]
>>> c = [‘fist’, ‘kick’, ‘palm’, ‘strike’]
>>> ‘ ‘.join([choice(a), choice(b), choice(c)])
‘thunderous snake fist’
[/python]
Leave a Reply