Skip to content Skip to sidebar Skip to footer

How To Get The Qualified Name Of The Currently Executing Function?

Python 3.3 introduced the __qualname__ attribute for function objects and class objects. It's easy to get the (unqualified) name and a code object for the currently executing funct

Solution 1:

You can use executing:

executing.Source.for_frame(frame).code_qualname(frame.f_code)

Solution 2:

I don't think you can, currently; see this thread.

Issue 13672 requests adding co_qualname to code objects, and issue 12857 requests making the called function available through the frame object. Both have patches attached.

Post a Comment for "How To Get The Qualified Name Of The Currently Executing Function?"