Printable string for 'self'
Don Taylor
nospamformeSVP at gmail.com
Wed Mar 15 15:16:25 EST 2006
Fredrik Lundh wrote:
> Q. How can my code discover the name of an object?
>
> A. The same way as you get the name of that cat you found on your
> porch: the cat itself cannot tell you its name, and it doesn't really
> care -- so the only way to find out what it's called is to ask all your
> neighbours if it's their cat... and don't be surprised if you'll find that
> it's known by many names, or no name at all!
>
> from:
>
> http://www.python.org/doc/faq/programming.html#how-can-my-code-discover-the-name-of-an-object
>
> (fwiw, the current crop of stray cats in my neighbourhood are known
> as "sune" and "the big fat red one")
I see.
--------------------
"This is a project on which we have been working for the last three
centuries since the lamasery was founded, in fact. It is somewhat alien
to your way of thought, so I hope you will listen with an open mind
while I explain it."
"Naturally."
"It is really quite simple. We have been compiling a list which shall
contain all the possible names of God."
---------------------
From "The Nine Billion Names of God" by Arthur C. Clarke.
http://www.geocities.com/rojodos/docs/9000000000.htm
> no, as long as you're aware that you're doing introspection, and that your
> code won't run in all Python environments.
Yes, it is introspection for a testing tool - not for production code.
Thanks,
Don.
More information about the Python-list
mailing list