How can a function find the function that called it?

kj no.email at please.post
Fri Dec 24 13:43:06 EST 2010


In <mailman.272.1293215190.6505.python-list at python.org> Daniel Urban <urban.dani at gmail.com> writes:

>On Fri, Dec 24, 2010 at 17:24, kj <no.email at please.post> wrote:
>> (BTW, I don't understand why inspect doesn't provide something as
>> basic as the *class* that the method belongs to, whenever applicable.
>> I imagine there's a good reason for this coyness, but I can't figure
>> it out.)

>One function object can "belong to" (be in the namespace of) more than
>one class, so there is no "the class".

There are many other properties that inspect reports on (e.g.
filename) that may not apply to an individual case.  For 99.9% of
methods, the class in which it was lexically defined would be good
enough.



More information about the Python-list mailing list