Skip to content

Instantly share code, notes, and snippets.

@snark
Created June 4, 2015 00:24
Show Gist options
  • Save snark/02bf10c8ccb57149f708 to your computer and use it in GitHub Desktop.
Save snark/02bf10c8ccb57149f708 to your computer and use it in GitHub Desktop.
Python types
scook:~ scook$ python3
Python 3.4.2 (default, Jan 7 2015, 11:54:58)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> type(None)
<class 'NoneType'>
>>> type(False)
<class 'bool'>
>>> type(3)
<class 'int'>
>>> type(2.51)
<class 'float'>
>>> type(0j)
<class 'complex'>
>>> type("hello")
<class 'str'>
>>> type( [1, 2, 3] )
<class 'list'>
>>> type( (0, 1) )
<class 'tuple'>
>>> type( {"foo": 0, "bar": False} )
<class 'dict'>
>>> type( {"a", "b", "c"} )
<class 'set'>
>>> class Door(object):
... pass
...
>>> backdoor = Door()
>>> type(backdoor)
<class '__main__.Door'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment