cpython (merge 3.2 -> default): Merge from 3.2 (#9254, #8982, #9788)

http://hg.python.org/cpython/rev/4a6cb2d9e906 changeset: 71605:4a6cb2d9e906 parent: 71601:91d6cabf77d6 parent: 71604:e37fa30c4be4 user: Éric Araujo <merwok@netwok.org> date: Fri Jul 29 18:10:12 2011 +0200 summary: Merge from 3.2 (#9254, #8982, #9788) files: Doc/library/argparse.rst | 17 ++++++++++------- Doc/library/atexit.rst | 4 +++- Doc/library/functions.rst | 11 ++--------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -110,7 +110,7 @@ :class:`ArgumentParser` parses args through the :meth:`~ArgumentParser.parse_args` method. This will inspect the command line, convert each arg to the appropriate type and then invoke the appropriate action. -In most cases, this means a simple namespace object will be built up from +In most cases, this means a simple :class:`Namespace` object will be built up from attributes parsed out of the command line:: >>> parser.parse_args(['--sum', '7', '-1', '42']) @@ -741,7 +741,7 @@ * ``parser`` - The ArgumentParser object which contains this action. -* ``namespace`` - The namespace object that will be returned by +* ``namespace`` - The :class:`Namespace` object that will be returned by :meth:`~ArgumentParser.parse_args`. Most actions add an attribute to this object. @@ -1352,11 +1352,14 @@ The Namespace object ^^^^^^^^^^^^^^^^^^^^ -By default, :meth:`~ArgumentParser.parse_args` will return a new object of type -:class:`Namespace` where the necessary attributes have been set. This class is -deliberately simple, just an :class:`object` subclass with a readable string -representation. If you prefer to have dict-like view of the attributes, you -can use the standard Python idiom via :func:`vars`:: +.. class:: Namespace + + Simple class used by default by :meth:`~ArgumentParser.parse_args` to create + an object holding attributes and return it. + +This class is deliberately simple, just an :class:`object` subclass with a +readable string representation. If you prefer to have dict-like view of the +attributes, you can use the standard Python idiom, :func:`vars`:: >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--foo') diff --git a/Doc/library/atexit.rst b/Doc/library/atexit.rst --- a/Doc/library/atexit.rst +++ b/Doc/library/atexit.rst @@ -9,7 +9,9 @@ The :mod:`atexit` module defines functions to register and unregister cleanup functions. Functions thus registered are automatically executed upon normal -interpreter termination. +interpreter termination. The order in which the functions are called is not +defined; if you have cleanup operations that depend on each other, you should +wrap them in a function and register that one. This keeps :mod:`atexit` simple. Note: the functions registered via this module are not called when the program is killed by a signal not handled by Python, when a Python fatal internal error diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1387,7 +1387,7 @@ .. note:: This is an advanced function that is not needed in everyday Python - programming. + programming, unlike :func:`importlib.import_module`. This function is invoked by the :keyword:`import` statement. It can be replaced (by importing the :mod:`builtins` module and assigning to @@ -1437,15 +1437,8 @@ names. If you simply want to import a module (potentially within a package) by name, - you can call :func:`__import__` and then look it up in :data:`sys.modules`:: + use :func:`importlib.import_module`. - >>> import sys - >>> name = 'foo.bar.baz' - >>> __import__(name) - <module 'foo' from ...> - >>> baz = sys.modules[name] - >>> baz - <module 'foo.bar.baz' from ...> .. rubric:: Footnotes -- Repository URL: http://hg.python.org/cpython
participants (1)
-
eric.araujo