get instance name inside of member function

Michael Hudson mwh at
Wed Jan 15 17:55:39 CET 2003

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

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


  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

  ....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*?"


  Never meddle in the affairs of NT. It is slow to boot and quick to
  crash.                                             -- Stephen Harris

More information about the Python-list mailing list