summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libdis.tex11
-rw-r--r--Doc/ref/ref6.tex20
2 files changed, 21 insertions, 10 deletions
diff --git a/Doc/lib/libdis.tex b/Doc/lib/libdis.tex
index e80515c..e6d3c77 100644
--- a/Doc/lib/libdis.tex
+++ b/Doc/lib/libdis.tex
@@ -301,6 +301,12 @@ is evaluated, the locals are passed to the class definition.
Returns with TOS to the caller of the function.
\end{opcodedesc}
+\begin{opcodedesc}{IMPORT_STAR}{}
+Loads all symbols not starting with '_' directly from the module TOS
+to the local namespace. The module is popped after loading all names.
+This opcode implements 'from module import *'.
+\begin{opcodedesc}
+
\begin{opcodedesc}{EXEC_STMT}{}
Implements \code{exec TOS2,TOS1,TOS}. The compiler fills
missing optional parameters with None.
@@ -411,8 +417,9 @@ modifies the name space.
\end{opcodedesc}
\begin{opcodedesc}{IMPORT_FROM}{namei}
-Imports the attribute \code{co_names[\var{namei}]}. The module to import
-from is found in TOS and left there.
+Loads the attribute \code{co_names[\var{namei}]} from the module found in
+TOS. The resulting object is pushed onto the stack, to be subsequently
+stored by a \code{STORE_FAST} instruction.
\end{opcodedesc}
\begin{opcodedesc}{JUMP_FORWARD}{delta}
diff --git a/Doc/ref/ref6.tex b/Doc/ref/ref6.tex
index dc50c27..008cf1c 100644
--- a/Doc/ref/ref6.tex
+++ b/Doc/ref/ref6.tex
@@ -443,8 +443,9 @@ It continues with the next cycle of the nearest enclosing loop.
\stindex{import}
\begin{verbatim}
-import_stmt: "import" module ("," module)*
- | "from" module "import" identifier ("," identifier)*
+import_stmt: "import" module ["as" name] ("," module ["as" name] )*
+ | "from" module "import" identifier ["as" name]
+ ("," identifier ["as" name] )*
| "from" module "import" "*"
module: (identifier ".")* identifier
\end{verbatim}
@@ -496,13 +497,16 @@ begin.
The first form of \keyword{import} statement binds the module name in the
local namespace to the module object, and then goes on to import the
-next identifier, if any. The \keyword{from} form does not bind the
-module name: it goes through the list of identifiers, looks each one
-of them up in the module found in step (1), and binds the name in the
-local namespace to the object thus found. If a name is not found,
+next identifier, if any. If the module name is followed by \keyword{as},
+the name following \keyword{as} is used as the local name for the module.
+The \keyword{from} form does not bind the module name: it goes through the
+list of identifiers, looks each one of them up in the module found in step
+(1), and binds the name in the local namespace to the object thus found.
+Like with the first form of \keyword{import}, an alternate local name can be
+supplied by specifying "\keyword{as} localname". If a name is not found,
\exception{ImportError} is raised. If the list of identifiers is replaced
-by a star (\samp{*}), all names defined in the module are bound,
-except those beginning with an underscore (\character{_}).
+by a star (\samp{*}), all names defined in the module are bound, except
+those beginning with an underscore (\character{_}).
\indexii{name}{binding}
\exindex{ImportError}