@@ -47,8 +47,9 @@ command::
47
47
48
48
>>> import fibo
49
49
50
- This does not enter the names of the functions defined in ``fibo `` directly in
51
- the current symbol table; it only enters the module name ``fibo `` there. Using
50
+ This does not add the names of the functions defined in ``fibo `` directly to
51
+ the current :term: `namespace ` (see :ref: `tut-scopes ` for more details);
52
+ it only adds the module name ``fibo `` there. Using
52
53
the module name you can access the functions::
53
54
54
55
>>> fibo.fib(1000)
@@ -75,27 +76,27 @@ These statements are intended to initialize the module. They are executed only
75
76
the *first * time the module name is encountered in an import statement. [# ]_
76
77
(They are also run if the file is executed as a script.)
77
78
78
- Each module has its own private symbol table , which is used as the global symbol
79
- table by all functions defined in the module. Thus, the author of a module can
79
+ Each module has its own private namespace , which is used as the global namespace
80
+ by all functions defined in the module. Thus, the author of a module can
80
81
use global variables in the module without worrying about accidental clashes
81
82
with a user's global variables. On the other hand, if you know what you are
82
83
doing you can touch a module's global variables with the same notation used to
83
84
refer to its functions, ``modname.itemname ``.
84
85
85
86
Modules can import other modules. It is customary but not required to place all
86
87
:keyword: `import ` statements at the beginning of a module (or script, for that
87
- matter). The imported module names are placed in the importing module's global
88
- symbol table .
88
+ matter). The imported module names, if placed at the top level of a module
89
+ (outside any functions or classes), are added to the module's global namespace .
89
90
90
91
There is a variant of the :keyword: `import ` statement that imports names from a
91
- module directly into the importing module's symbol table . For example::
92
+ module directly into the importing module's namespace . For example::
92
93
93
94
>>> from fibo import fib, fib2
94
95
>>> fib(500)
95
96
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
96
97
97
98
This does not introduce the module name from which the imports are taken in the
98
- local symbol table (so in the example, ``fibo `` is not defined).
99
+ local namespace (so in the example, ``fibo `` is not defined).
99
100
100
101
There is even a variant to import all names that a module defines::
101
102
@@ -580,5 +581,5 @@ modules found in a package.
580
581
.. rubric :: Footnotes
581
582
582
583
.. [# ] In fact function definitions are also 'statements' that are 'executed'; the
583
- execution of a module-level function definition enters the function name in
584
- the module's global symbol table .
584
+ execution of a module-level function definition adds the function name to
585
+ the module's global namespace .
0 commit comments