Created
April 8, 2012 03:57
-
-
Save Nimster/2334466 to your computer and use it in GitHub Desktop.
Quick reference to some common python idioms/capabilities - mainly to serve as a reminder for me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
collections.defaultdict(lambda: 0) # Hash map with default values | |
l = [t for t in l if not t in s] # Given a list l and a set s, returns l without all the elements in s | |
fun_with_many_args(*[1, 2, 3]) # Splat an array into an argument list | |
fun_with_named_args(**{'arg1': 1, 'arg2': 2}) # Splat a map (dictionary) for named argument functions! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment