Python/scripts
From Christoph's Personal Wiki
This article will list a bunch of quick-and-dirty Python tips-and-tricks, examples, code, etc.
Generate a random set of characters
Note: Useful for creating random user passwords after a reset.
$ python -c 'import random; print "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789\!@#$%^&*(-_=+)") for i in range(9)])'
Lambda functions
In stead of creating a new function of
f(x): return x + 1
You could use a lambda function inline, like so:
function_var = lambda x: x + 1 >>> print function_var(2) 3