In Python is there a way to get the code object of top level code?
Is it possible to get the code object of top level code within a module? For example, if you have a python file like this: myvar = 1 print(‘hello from top level’) def myfunction(): print(‘hello from function’) and you want to access the code object for myfunction, then you can use myfunction.__code__. For example, myfunction.__code__.co_consts … Read more