Python Forum

Full Version: get type of a value as a simple string
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
what is the best way to get just a string for the type of a value? would this be sufficient?
ts = str(type(foo)).split("'")
If I understand correctly objective then one can do:

>>> foo = 'abc'
>>> type(foo).__name__
'str'