Skip to content

Instantly share code, notes, and snippets.

@mvanveen
Created March 25, 2011 05:07
Show Gist options
  • Save mvanveen/886392 to your computer and use it in GitHub Desktop.
Save mvanveen/886392 to your computer and use it in GitHub Desktop.
Type checking case switch in python
import sys
def retr(item):
return({ type('') : lambda x: sys.stdout.write(x),
type([]) : lambda item: ''.join(retr(x) for x in item)
}[type(item)](item)
retr('lol')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment