When reading 6. Modules, I encounter
Each module has its own private symbol table, which is used as the global symbol table by all functions defined in the module. Thus, the author of a module can use global variables in the module without worrying about accidental clashes with a user’s global variables. On the other hand, if you know what you are doing you can touch a module’s global variables with the same notation used to refer to its functions, modname.itemname.
Module's 'private symbol table' and functions' 'global symbol table' confuse me.
In Symbol table: Wikipedia, it reads:
The Python programming language includes extensive support for creating and manipulating symbol tables.[2] Properties that can be queried include whether a given symbol is a free variable or a bound variable, whether it is block scope or global scope, whether it is imported, and what namespace it belongs to.
It seems a little more complicated.
How to understand the private and global symbol table, could I print them?
Follow PM 2Ring's comment, I create a script:
#symbol_table.py
print(global())
$ python symbol_table.py
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x10bddf278>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, '__file__': 'symbol_table.py', '__cached__': None}
Is {'__name__': '__main__', '__doc__': None, '
called global symble table?