name of an instance

andrea valle andrea.valle at unito.it
Mon Nov 1 22:09:03 CET 2004


Thanks,
That was a possibility. But my idea was to not requiring the instance 
to know explicitly about its name. I solved passing my receiving object 
not the instance's name, but the instance directly.

-a-



On 1 Nov 2004, at 20:03, Terry Reedy wrote:

>
> "andrea valle" <andrea.valle at unito.it> wrote in message
> news:6FAE7CBE-2BF1-11D9-841C-0003939C968C at unito.it...
>> How do I access the name of an instance?
>
> By giving __init__ a name param that you store as self.name so that the
> instance really has a name.  (def and class statements do something
> similar)
> ---
> class MyClass:
>   def __init__(self, name='No name'):
>     self.name = name
>   def __str__(self): return self.name
>
> Terry J. Reedy
>
>
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>
Andrea Valle
Laboratorio multimediale "G. Quazza"
Facoltà di Scienze della Formazione
Università degli Studi di Torino
andrea.valle at unito.it




More information about the Python-list mailing list