name of object inside it's methods?

Darrell darrell at dorb.com
Sun Feb 27 13:16:11 EST 2000


Take two.
As Fredrik said, "you can't do that"

In case you want to know the name of the specific instance, I use the full
name.
The address will be unique unless you start moving this instance between
address spaces.

>>> class A:
...     pass
...
>>> a=A()
>>> a
<__main__.A instance at 8813b8>

<alv50855 at batman.tamucc.edu> wrote in message
> 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
>
>
> --
> http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list