diff options
Diffstat (limited to 'Doc/tutorial')
| -rw-r--r-- | Doc/tutorial/errors.rst | 3 | ||||
| -rw-r--r-- | Doc/tutorial/modules.rst | 25 |
2 files changed, 8 insertions, 20 deletions
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst index cedffd5ba6..a9687e5fbc 100644 --- a/Doc/tutorial/errors.rst +++ b/Doc/tutorial/errors.rst @@ -344,8 +344,7 @@ occurred in the :keyword:`try` clause and has not been handled by an been executed. The :keyword:`finally` clause is also executed "on the way out" when any other clause of the :keyword:`try` statement is left via a :keyword:`break`, :keyword:`continue` or :keyword:`return` statement. A more -complicated example (having :keyword:`except` and :keyword:`finally` clauses in -the same :keyword:`try` statement works as of Python 2.5):: +complicated example:: >>> def divide(x, y): ... try: diff --git a/Doc/tutorial/modules.rst b/Doc/tutorial/modules.rst index 279afc812b..eee989faa8 100644 --- a/Doc/tutorial/modules.rst +++ b/Doc/tutorial/modules.rst @@ -493,35 +493,24 @@ packages. Intra-package References ------------------------ -The submodules often need to refer to each other. For example, the -:mod:`surround` module might use the :mod:`echo` module. In fact, such -references are so common that the :keyword:`import` statement first looks in the -containing package before looking in the standard module search path. Thus, the -:mod:`surround` module can simply use ``import echo`` or ``from echo import -echofilter``. If the imported module is not found in the current package (the -package of which the current module is a submodule), the :keyword:`import` -statement looks for a top-level module with the given name. - When packages are structured into subpackages (as with the :mod:`sound` package in the example), you can use absolute imports to refer to submodules of siblings packages. For example, if the module :mod:`sound.filters.vocoder` needs to use the :mod:`echo` module in the :mod:`sound.effects` package, it can use ``from sound.effects import echo``. -Starting with Python 2.5, in addition to the implicit relative imports described -above, you can write explicit relative imports with the ``from module import -name`` form of import statement. These explicit relative imports use leading -dots to indicate the current and parent packages involved in the relative -import. From the :mod:`surround` module for example, you might use:: +You can also write relative imports, with the ``from module import name`` form +of import statement. These imports use leading dots to indicate the current and +parent packages involved in the relative import. From the :mod:`surround` +module for example, you might use:: from . import echo from .. import formats from ..filters import equalizer -Note that both explicit and implicit relative imports are based on the name of -the current module. Since the name of the main module is always ``"__main__"``, -modules intended for use as the main module of a Python application should -always use absolute imports. +Note that relative imports are based on the name of the current module. Since +the name of the main module is always ``"__main__"``, modules intended for use +as the main module of a Python application must always use absolute imports. Packages in Multiple Directories |
