Skip to content

Instantly share code, notes, and snippets.

@chen206
Created November 16, 2012 02:05
Show Gist options
  • Save chen206/4083275 to your computer and use it in GitHub Desktop.
Save chen206/4083275 to your computer and use it in GitHub Desktop.
python snippets
>>> t = ((1, 'a'),(2, 'b'))
>>> dict((y, x) for x, y in t)
{'a': 1, 'b': 2}
>>> [1] * 5
[1, 1, 1, 1, 1]
>>> ['%s'] * 5
['%s', '%s', '%s', '%s', '%s']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment