getting from code object to class/function

Michael Hudson mwh at python.net
Thu Apr 8 07:55:27 EDT 2004


Skip Montanaro <skip at pobox.com> writes:

>     >> There is, however, no direct way back from the code object to (for
>     >> example) the class and method which "own" that object.  I didn't see
>     >> anything obvious in the inspect module that would allow me to worm
>     >> around this problem.
> 
>     mwh> gc.get_referrers?
> 
> Interesting idea.

I'm not sure it'll work though: I don't think code objects participate
in GC, so I don't know if function's traverse function call the
callback on the code object.

That said, I've just tried it, and it does work :-)

Cheers,
mwh

-- 
  We've had a lot of problems going from glibc 2.0 to glibc 2.1.
  People claim binary compatibility.  Except for functions they
  don't like.                       -- Peter Van Eynde, comp.lang.lisp




More information about the Python-list mailing list