The typename
module defines a single function also called typename
which returns the name of the
type of any object as a string.
Its purpose is purely aesthetic, to avoid unsightly constructs such as type(obj).__name__
or the
ghastly obj.__class__.__name__
.
The typename
package is available on the Python Package Index (PyPI):
Typename should work with any version of Python 3. To install:
With pip
from PyPI:
pip install typename
>>> from typename import typename
>>> x = 5
>>> typename(x)
'int'