Get reference to parents locals() from imported module
Is there some way to establish a reference from with a module being `imported ` to its parent (importer) module's, locals() so that I can read an variable from there as the file gets imported? I can establish the name of the importer like this, albeit I had hoped the might be a cleaner way, but how can I get a reference to its locals? import inspect if __name__ != '__main__': for frame in inspect.stack()[1:]: if frame.filename[0] != '<': print(f"{frame.filename=}") break
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.