[Python-ideas] Standard way to get caller name and easy call stack access

Eric Snow ericsnowcurrently at gmail.com
Wed Mar 28 03:30:08 CEST 2012

On Tue, Mar 27, 2012 at 9:14 AM, Robert Kern <robert.kern at gmail.com> wrote:
> On 3/27/12 2:33 PM, Steven D'Aprano wrote:
>> * Not all functions have meaningful names (think lambdas); or their name
>> may be
>> ambiguous (think functions produced by factory functions).
> One problem with this is that some of the intermediate frames (at the very
> least, the root frame) won't be functions but rather executed code in the
> form of module-level code or exec'ed strings. Furthermore, in CPython at
> least, it is difficult to go from the code object (which is what you have
> available) to its owning function object (if there is one). You can get the
> (well, a) name from the code object, though.

Here's a solution for the "this frame is the result of calling which
function?" question:


I think it strikes the right balance between providing something
new/useful and not making it too accessible.


> --
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless enigma
>  that is made terrible by our own mad attempt to interpret it as though it
> had
>  an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas

More information about the Python-ideas mailing list