diff options
Diffstat (limited to 'Doc/tutorial')
-rw-r--r-- | Doc/tutorial/interpreter.rst | 2 | ||||
-rw-r--r-- | Doc/tutorial/modules.rst | 22 |
2 files changed, 11 insertions, 13 deletions
diff --git a/Doc/tutorial/interpreter.rst b/Doc/tutorial/interpreter.rst index e85f62e..027c5e2 100644 --- a/Doc/tutorial/interpreter.rst +++ b/Doc/tutorial/interpreter.rst @@ -31,7 +31,7 @@ command into the command prompt in a DOS box:: Typing an end-of-file character (:kbd:`Control-D` on Unix, :kbd:`Control-Z` on Windows) at the primary prompt causes the interpreter to exit with a zero exit status. If that doesn't work, you can exit the interpreter by typing the -following commands: ``import sys; sys.exit()``. +following command: ``quit()``. The interpreter's line-editing features usually aren't very sophisticated. On Unix, whoever installed the interpreter may have enabled support for the GNU diff --git a/Doc/tutorial/modules.rst b/Doc/tutorial/modules.rst index 1023ba8..d4bfbda 100644 --- a/Doc/tutorial/modules.rst +++ b/Doc/tutorial/modules.rst @@ -107,6 +107,10 @@ In most cases Python programmers do not use this facility since it introduces an unknown set of names into the interpreter, possibly hiding some things you have already defined. +Note that in general the practice of importing ``*`` from a module or package is +frowned upon, since it often causes poorly readable code. However, it is okay to +use it to save typing in interactive sessions. + .. note:: For efficiency reasons, each module is only imported once per interpreter @@ -445,14 +449,9 @@ Importing \* From a Package Now what happens when the user writes ``from sound.effects import *``? Ideally, one would hope that this somehow goes out to the filesystem, finds which -submodules are present in the package, and imports them all. Unfortunately, -this operation does not work very well on Windows platforms, where the -filesystem does not always have accurate information about the case of a -filename. On these platforms, there is no guaranteed way to know whether a file -:file:`ECHO.PY` should be imported as a module :mod:`echo`, :mod:`Echo` or -:mod:`ECHO`. (For example, Windows 95 has the annoying practice of showing all -file names with a capitalized first letter.) The DOS 8+3 filename restriction -adds another interesting problem for long module names. +submodules are present in the package, and imports them all. This could take a +long time and importing sub-modules might have unwanted side-effects that should +only happen when the sub-module is explicitly imported. The only solution is for the package author to provide an explicit index of the package. The :keyword:`import` statement uses the following convention: if a package's @@ -487,10 +486,9 @@ current namespace because they are defined in the :mod:`sound.effects` package when the ``from...import`` statement is executed. (This also works when ``__all__`` is defined.) -Note that in general the practice of importing ``*`` from a module or package is -frowned upon, since it often causes poorly readable code. However, it is okay to -use it to save typing in interactive sessions, and certain modules are designed -to export only names that follow certain patterns. +Although certain modules are designed to export only names that follow certain +patterns when you use ``import *``, it is still considered bad practise in +production code. Remember, there is nothing wrong with using ``from Package import specific_submodule``! In fact, this is the recommended notation unless the |