Skip to content

Instantly share code, notes, and snippets.

@bradmontgomery
Created July 7, 2012 02:41
Show Gist options
  • Save bradmontgomery/3064005 to your computer and use it in GitHub Desktop.
Save bradmontgomery/3064005 to your computer and use it in GitHub Desktop.
Is this too clever?
def accepts_two_types(v):
if type(v) == type(1):
print "%s is an integer" % (v)
elif type(v) == type(''):
print "%s is assumed to be a string" % (v)
else:
raise TypeError, "not a string or int!"
if __name__ == "__main__":
accepts_two_types(42)
accepts_two_types("forty two")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment