Official reason for omitting inspect.currentcallable() ?





Is there an *explicitly stated* reason (e.g. in a PEP, or in some
python dev list message) for why the inspect module (at least for
Python 2.7) does not include anything like a "currentcallable()"
function that would *stably*[1] return the currently executing
callable object?

(It seems unlikely that the absence in the inspect module of anything
even remotely like such a currentcallable is merely an oversight,
considering how many introspection facilities the inspect module
provides. It seems far more likely that this absence is either
due to some fundamental limitation of Python that makes it impossible
to fully specify such a function, or it is the result of a deliberate
policy against including such a function in inspect.)

Thanks!

[1] By "stably" above I mean, e.g., that the value returned by the
top-level function (object) defined by

def spam():
return inspect.currentcallable()

is *invariant*, in contrast to the value returned by the top-level
function (object) defined by

def ham():
return ham

which is whatever the current value of the 'ham' global happens to
be.

.



Relevant Pages

  • text adventure question
    ... I am working on a text adventure game for python to get back into ... def character_sheet: ... global reputation ... print "Please choose another command. ...
    (comp.lang.python)
  • Re: noob question: "TypeError" wrong number of args
    ... or it's newer syntactic-sugar-version would become somewhat more ... Python source code and outputs the same source code with only one change: ... insert the string 'self" as the first parameter of every "def ... Python code, which is unavoidable for such a syntactic change. ...
    (comp.lang.python)
  • Re: Python 3K or Python 2.9?
    ... function/method argument that might as well be hidden in the compiler ... You could add some syntax to Python such that '.x' was equivalent to ... def factory: ... C.method = foo ...
    (comp.lang.python)
  • [PATCH] tracecmd: Add initial python tracecmd API
    ... Subject: tracecmd: Add initial python tracecmd API ... Add an object oriented python API in a new tracecmd.py module. ... -print "Cycling through the events for each CPU" ... def comm: ...
    (Linux-Kernel)
  • Crude statistics on the standard library
    ... def browse_stdlib: ... # remove some obsolete modules ('this' + DeprecationWarning) ... Parts of output of python -i statsmod.py ... referrers of __future__ ...
    (comp.lang.python)