converting return from type() function in python to string

LuckyLucks used Ask the Experts™

i have a return type from the type() function in python. I would like to convert this to string? is it possible and how?

something that would look like this:
<type 'A'>.tostring()

The __sr__ and __repr__ don't exist in class A.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If the class A does not have its own __str__() then you have to write your own function that will display the content of the object the way you want.

The type object has __str__, so you can just str(type(xyz)). For debugging, the print(type(xyz)) will convert it to string internally.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial