How can I know the name of "caller"

John Nagle nagle at
Wed Jun 20 06:52:21 CEST 2007

billiejoex wrote:
> Hi there,
> unfortunately, I'm compelled to apply a sort of monkey patching at the
> code of an existing libreary that I can't modify directly.
> ...(if it is possible) how can I get, from method "called", the name
> of function/method that called it (in this case "caller")?

     Bad idea.

     Note, though, that within Python, you can easily replace existing
function definitions with your own.  This is something of a desperation
measure, but it works.

    I have a small collection of patches to the standard Python libraries
which I import.  (I've reported all of them in the tracker as bugs, and some 
later version of Python will contain the fixes. But that can take years.)

				John Nagle

More information about the Python-list mailing list