Context-aware return

Paul Rubin no.email at nospam.invalid
Thu Sep 10 15:19:59 EDT 2015


Steven D'Aprano <steve at pearwood.info> writes:
> I want the function to know its own context.
> I don't mind if it is CPython only, or if it is a bit expensive.

That sounds crazy but if it's really what you want, you can probably
fake it by examining the control stack using the backtrace module.  I
remember doing some hack of raising and catching an exception in order
to retrieve the backtrace, but there might be a cleaner way that I
didn't bother researching since it was just for a quick debugging
problem.



More information about the Python-list mailing list