sys.-getframe

How can I preserve or identify a caller's stack frame?

My brain feels slow today. I'm writing pre/post/invariants in Python using decorators. Currently, I need each call to specify the locals and globals for context, and this feels ugly. Is there a way to get the locals and globals from the decorator application level even though it's an arbitrary depth. That is, I'm trying to make ...

How can I figure out in my module if the main program uses a specific variable?

I know this does not sound Pythonic, but bear with me for a second. I am writing a module that depends on some external closed-source module. That module needs to get instantiated to be used (using module.create()). My module attempts to figure out if my user already loaded that module (easy to do), but then needs to figure out if the ...