Answers for "python method which name of class"

2

how to get the name of a class in python

class test:
  @property
  def cls_name(self):
    return self.__class__.__name__
  
  @property
  def cls_name_2(self):
    return type(self).__name__
  
  @classmethod 
	def cls_name_3(cls):
		return cls.__name__
      
ins = test()

print(ins.cls_name)
print(ins.cls_name_2)
print(ins.cls_name_3())
Posted by: Guest on September-10-2021
1

python class name

instance.__class__.__name__
Posted by: Guest on October-16-2020

Code answers related to "python method which name of class"

Python Answers by Framework

Browse Popular Code Answers by Language