name of object inside it's methods?
Darrell
darrell at dorb.com
Sun Feb 27 11:01:54 EST 2000
>>> class A:
... def a(self):
... print str(self.__class__)
...
>>> A().a()
__main__.A
> can someone fill in the blank
>
> -------------------------------
> class Hello:
> def __init__(self, x):
> self.x = x
>
> def classname(self):
> <blank>
>
> -------------------------------
>
> >>>from hello import *
> >>>clown = Hello(1)
> >>>clown.classname()
> clown
>
> In other words I want the method to print the name of the object that it
> belongs to
>
More information about the Python-list
mailing list