You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/SPECIFICATION.html
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -835,6 +835,8 @@
835
835
836
836
Thefirstargumentmustbeanidentifiernamingamodule;theinterpreterfirstlooksforafilenamed`<name>.pre`inthesamedirectoryasthereferringsourcefile.Whenthereferringsourceisprovidedviathe`-source`stringliteralmode,theprimarysearchdirectoryistheprocess's current working directory. If the module file is not found there, the interpreter will additionally attempt to load the file from a `lib` subdirectory located alongside the interpreter implementation (that is, `<interpreter_dir>/lib/<name>.pre`, where `<interpreter_dir>` is the directory containing the interpreter script or executable).
Theimportedfileisparsedandexecutedinitsownisolatedtop-levelenvironmentonthefirstimportduringagiveninterpreterinvocation: top-levelassignmentsandfunctiondefinitionsintheimportedmoduledonotdirectlymutatethecaller's environment during execution. During that execution unqualified identifiers (for example, `x` or `helper`) refer to names in the module'sowntop-levelnamespace.Qualifiedidentifiers(forexample,`other.FOO`)referonlytothedottednamesthatthemoduleitselfhascreatedorimported;thosequalifiedbindingsarescopedtothemodule'snamespace.
839
841
840
842
Afterthemodulefinishesexecutingthefirsttime,theinterpretercachesthemodule's top-level environment and the module-qualified function objects. Subsequent `IMPORT` calls for the same module identifier within the same interpreter process reuse that cached namespace/instance and do not re-execute the module source. Callers importing the same module later will observe the same shared module environment (that is, the same binding objects and the same function objects). By default bindings are exposed under the module'sowndottedprefix(`module.FOO`,`module.bar`,etc.);however,iftheimportersuppliedanaliasthebindingsareinsteadexposedunderthealiasprefix(`alias.FOO`,`alias.bar`).Multipledifferentaliasesforthesamemoduleidentifierwilleachgettheirowndottedviewintothesamecachedmoduleinstance.Ifthemoduleimportedothermodulesduringitsexecution,thosenestedqualifiedbindingsarepreservedinthecachednamespaceandremainaccessibleviathesamedottedpaths(forexample,`module.other.SYM`or`alias.other.SYM`or`module.alias.SYM`).
0 commit comments