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
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -826,8 +826,6 @@
826
826
827
827
Packageimports: Prefixsupportspackagenamespacesusing`..`asthepackageseparator.Thecanonicalformis`package..subpackage..module`.When`IMPORT(pkg)`isusedtheinterpreterwillpreferapackagelayoutandattempttoload`pkg/init.pre`fromthereferringsource's directory (falling back to the interpreter `lib/` directory). If a directory named `pkg` exists but contains no `init.pre` the import raises a clear error. When `IMPORT(pkg..mod)` is used the interpreter resolves to `pkg/mod.pre` (or the corresponding file under `lib/`). When a package directory and a same-named module file both exist in the same search location, the package takes precedence. Items within the package are still imported using their full dotted names (for example, `pkg..mod.FOO`).
828
828
829
-
-`IMPORT_PATH(STR: path)`-LoadsaPrefixmodulefromtheabsolutefilesystem`path`providedasa`STR`.Theargumentmustbeanabsolutepathtoa`.pre`sourcefile.Theimportedmoduleistreatedthesameas`IMPORT`withrespecttoparsing,executionisolation,function/modulecaching,andcompanionextensionloading(companion`<module>.prex`alongsidetheresolvedfileandabuilt-in`ext/<module>.py` are both checked and loaded if present). The module's basename (filename without extension) is used as the module identifier for qualifying exported bindings.
830
-
831
829
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).
832
830
833
831
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's namespace.
-`IMPORT_PATH(STR: path)`-LoadsaPrefixmodulefromtheabsolutefilesystem`path`providedasa`STR`.Theargumentmustbeanabsolutepathtoa`.pre`sourcefile.Theimportedmoduleistreatedthesameas`IMPORT`withrespecttoparsing,executionisolation,function/modulecaching,andcompanionextensionloading(companion`<module>.prex`alongsidetheresolvedfileandabuilt-in`ext/<module>.py` are both checked and loaded if present). The module's basename (filename without extension) is used as the module identifier for qualifying exported bindings.
841
+
841
842
- `EXPORT(SYMBOL: symbol,MODULE: module):INT` - Adds the caller's binding for the identifier `symbol` into the namespace of the imported module named by the identifier `module`. The first argument must be an identifier (not a string literal); its current value in the caller's environment is copied into the imported module's namespace and becomes available as the qualified name `module.symbol` in the caller's environment. The second argument must be an identifier naming a previously-imported module; if the module has not been imported yet, the interpreter raises a runtime error (rewrite: EXPORT). `EXPORT` returns `INT` 0 on success.
0 commit comments