How can I get the name of an object???
Remco Gerlich
scarblac-spamtrap at pino.selwerd.nl
Thu Apr 27 11:07:55 EDT 2000
spex66 at my-deja.com wrote in comp.lang.python:
> In article <etd8zy03m44.fsf at w20-575-108.mit.edu>,
> Alex <cut_me_out at hotmail.com> wrote:
> >
> > An object could be referred to by any number of names:
> >
> > dd = zz ()
> > ee = dd
> >
> > Which name for the object do you wish to know? ee or dd?
>
> dd or in other words, the name of the FIRST made instance...
What would happen in the following cases:
1)
dd = zz()
ee = dd
del dd
print ee.__name__
2)
dd = [xx(), yy(), zz()]
print dd[2].__name__
3)
print zz().__name__
Classes have a name (the one used in their class: statement).
Instances have no name, period.
But why would you need it? In most cases where people try to use something
like this, dictionaries are a solution.
--
Remco Gerlich, scarblac at pino.selwerd.nl
"This gubblick contains many nonsklarkish English flutzpahs, but the
overall pluggandisp can be glorked from context" (David Moser)
More information about the Python-list
mailing list