How To Get Class Name In Python — pythonpip.com

Class in Python

How To Get class name in Python

  • To get the type or class of an Object/Instance, use the type() method and __name__.
  • The type or class of the Object/Instance can be determined by combining the __class__ and __name__ variables.
data = "pythonpip" print(type(data).__name__)
a_list = [] data_type = type(a_list) class_name = data_type.__name__ print(class_name)

How to Check Class name in Python 2X

class Test: pass t = Test() print(str(t.__class__))

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store