Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the string with name of a class?

Tags:

python

What method do I call to get the name of a class?

like image 662
clahey Avatar asked Sep 16 '08 18:09

clahey


People also ask

Can a class name be String?

String is already the name of a class.

How do I get the class of a String in Python?

Python __str__() This method returns the string representation of the object. This method is called when print() or str() function is invoked on an object. This method must return the String object.

How do you find the class name of an object?

If you have a JavaSW object, you can obtain it's class object by calling getClass() on the object. To determine a String representation of the name of the class, you can call getName() on the class.


1 Answers

In [1]: class test(object):    ...:     pass    ...:   In [2]: test.__name__ Out[2]: 'test' 
like image 198
Mr Shark Avatar answered Sep 21 '22 08:09

Mr Shark