Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rweir
Forked from rbpasker/gist:e2b188fa56f9be0d956c
Created January 12, 2014 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rweir/feab6f43925ac6a05e31 to your computer and use it in GitHub Desktop.
Save rweir/feab6f43925ac6a05e31 to your computer and use it in GitHub Desktop.
# some actions to be performed on
actions = { 'k1' : lambda x : this.mangle(x),
'k2' : lambda x : x.lowercase(),
'k3' : lambda x : x[0]
}
for id in sorted(file.iterkeys()):
action = actions.get(id)
if action != None:
print action[file[id]]()
# input
file = { 'k1' : 'abc', 'k2' : 'DeF' , 'k3' : 'baz' }
# prints:
this.mangle('abc') # actually the value of this
def
b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment