get instance name inside of member function

Michael Hudson mwh at python.net
Wed Jan 15 11:55:39 EST 2003


Ralf Oberländer <ralf.oberlaender at emsys.de> writes:

> Hi gurus,
> 
> is it possible to get the name of the instance inside a member function:

>From http://www.amk.ca/quotations/python-quotes/page-8.html:

  The same way as you get the name of that cat you found on your
  porch: the cat (object) 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 (namespaces) if it's their cat
  (object)...

  ....and don't be surprised if you'll find that it's known by many
  names, or no name at all!

Fredrik Lundh, 3 Nov 2000, in answer to the question "How can I get the
name of a variable from C++ when I have the PyObject*?"

Cheers,
M.

-- 
  Never meddle in the affairs of NT. It is slow to boot and quick to
  crash.                                             -- Stephen Harris
               -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html




More information about the Python-list mailing list