Python Forum
type of object as a string - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: type of object as a string (/thread-22887.html)



type of object as a string - Skaperen - Dec-01-2019

i need to get the type of an object as a string, as in [] -> 'list'. does anything already exist for this or do i need to use my own function?

def typestr(obj):
    return str(type(obj)).split("'")[1]



RE: type of object as a string - midarq - Dec-02-2019

Try
type([]).__name__