Get the class name
Gary Herron
gherron at islandtraining.com
Mon Jun 8 11:33:26 EDT 2009
Kless wrote:
> Is there any way of to get the class name to avoid to have that write
> it?
>
> ---------------
> class Foo:
> super(Foo, self)
> ---------------
>
>
> * Using Py 2.6.2
>
The question does not make sense:
"to have WHAT write WHAT",
and the code is wrong:
the call to super fails
But even so, perhaps this will answer your question
>>> class Foo:
... pass
...
>>> print Foo.__name__
Foo
>>> c = Foo
>>> print c.__name__
Foo
>>> ob = Foo()
>>> print ob.__class__.__name__
Foo
Gary Herron
More information about the Python-list
mailing list