how to print class names, not references

Gerhard Häring gh_pythonlist at gmx.de
Sun Mar 17 21:16:33 EST 2002


* a.clarke11 <a.clarke11 at pop.ntlworld.com> [2002-03-18 01:36 +0000]:
> Hi,
> I wrote a function of x, where later in the program x is substituted by
> class names. In the function, print x is used, but this returns
> <__main__.Player instance at 0x38b1ce90> rather than the plain old class
> name that  I wanted.
> How can I print the name instead?
> Thanks for your help, Pythoneers...
 
Quick hint: x.__class__.__name__

Should be in the docs, but I'm too lazy to look it up right now.

Gerhard
-- 
This sig powered by Python!
Außentemperatur in München: 8.1 °C      Wind: 1.2 m/s




More information about the Python-list mailing list