max(01)* wrote:
> hi.
> 
> is there a way to define a class method which prints the instance name?
> 
> e.g.:
> 
>>>> class class_1:
> ...   def myName(self):
> ...     ????what should i do here????
> ...
>>>> instance_1 = class_1()
>>>> instance_1.myName()
> 'instance_1'
>>>>
> 
> bye
> 
> macs

What should the following do, you think?

>>> a=class_1()
>>> b=a
>>> b is a
True
>>> b.myName()
????print what????

There is no such thing as "the" instance name.
(a and b both point to the same instance, in my example)

Also: why do you want this? It smells like you're
actually looking for the use of a dict to do your job.

--Irmen
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to