In JavaScript it is possible to get a reference to the function
when inside it, using a special variable/property arguments.callee
.
It can be useful, for example, to define recursive anonymous functions
(but not only for that).
The same is not so easy in Python, as far as I know.
But I suppose it may possible using the inspect
module,
or some arcane techniques.
Could you please show me how it could be done?
I am ware of the questions
- Python: getting a reference to a function from inside itself
- how can python function access its own attributes?
That is not what I'm looking for, though the names sound good.