Created
March 25, 2011 05:07
-
-
Save mvanveen/886392 to your computer and use it in GitHub Desktop.
Type checking case switch in python
This file contains 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
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