how to print class names, not references

Terry Reedy tejarex at yahoo.com
Sun Mar 17 22:06:23 EST 2002


"a.clarke11" <a.clarke11 at pop.ntlworld.com> wrote in message
news:3C9544B5.47CD0918 at pop.ntlworld.com...
> 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?

grab the string that tells too much: toomuch = str(x).  then pull out
the part you want -- which is perhaps the definition name between the
first '.' and first ' '.

Terry J. Reedy






More information about the Python-list mailing list