Skip to content

Instantly share code, notes, and snippets.

@mdogo
Created February 13, 2013 19:19
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 mdogo/4947278 to your computer and use it in GitHub Desktop.
Save mdogo/4947278 to your computer and use it in GitHub Desktop.
Dynamic casting of basic types on Python
getattr(__builtin__, type_of)(value)
# Where type_of is a string with the casting type and value the value to cast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment