Context-aware return

Paul Rubin at nospam.invalid
Thu Sep 10 21:19:59 CEST 2015

Steven D'Aprano <steve at> 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

More information about the Python-list mailing list