summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/collections.rst2
-rw-r--r--Doc/library/exceptions.rst18
-rw-r--r--Doc/library/subprocess.rst22
3 files changed, 16 insertions, 26 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 3048a03..bcedc15 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -709,7 +709,7 @@ a fixed-width print format:
Point: x= 3.000 y= 4.000 hypot= 5.000
Point: x=14.000 y= 0.714 hypot=14.018
-The subclass shown above sets ``__slots__`` to an empty tuple. This keeps
+The subclass shown above sets ``__slots__`` to an empty tuple. This helps
keep memory requirements low by preventing the creation of instance dictionaries.
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index ceebf5e..b53f670 100644
--- a/Doc/library/exceptions.rst
+++ b/Doc/library/exceptions.rst
@@ -3,20 +3,12 @@
Built-in Exceptions
===================
-.. module:: exceptions
- :synopsis: Standard exception classes.
-
-
-Exceptions should be class objects. The exceptions are defined in the module
-:mod:`exceptions`. This module never needs to be imported explicitly: the
-exceptions are provided in the built-in namespace as well as the
-:mod:`exceptions` module.
-
.. index::
statement: try
statement: except
-For class exceptions, in a :keyword:`try` statement with an :keyword:`except`
+In Python, all exceptions must be instances of a class that derives from
+:class:`BaseException`. In a :keyword:`try` statement with an :keyword:`except`
clause that mentions a particular class, that clause also handles any exception
classes derived from that class (but not exception classes from which *it* is
derived). Two exception classes that are not related via subclassing are never
@@ -44,7 +36,7 @@ programmers are encouraged to at least derive new exceptions from the
defining exceptions is available in the Python Tutorial under
:ref:`tut-userexceptions`.
-The following exceptions are only used as base classes for other exceptions.
+The following exceptions are used mostly as base classes for other exceptions.
.. XXX document with_traceback()
@@ -99,8 +91,8 @@ The following exceptions are only used as base classes for other exceptions.
In this last case, :attr:`args` contains the verbatim constructor arguments as a
tuple.
-The following exceptions are the exceptions that are actually raised.
+The following exceptions are the exceptions that are usually raised.
.. exception:: AssertionError
@@ -369,10 +361,10 @@ The following exceptions are the exceptions that are actually raised.
associated value is a string indicating the type of the operands and the
operation.
+
The following exceptions are used as warning categories; see the :mod:`warnings`
module for more information.
-
.. exception:: Warning
Base class for warning categories.
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index 72ea8c6..698e535 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -136,10 +136,9 @@ This module defines one class called :class:`Popen`:
.. note::
- If specified, *env* must provide any variables required
- for the program to execute. On Windows, in order to run a
- `side-by-side assembly`_ the specified *env* **must** include a valid
- :envvar:`SystemRoot`.
+ If specified, *env* must provide any variables required for the program to
+ execute. On Windows, in order to run a `side-by-side assembly`_ the
+ specified *env* **must** include a valid :envvar:`SystemRoot`.
.. _side-by-side assembly: http://en.wikipedia.org/wiki/Side-by-Side_Assembly
@@ -188,7 +187,7 @@ This module also defines four shortcut functions:
The arguments are the same as for the Popen constructor. Example::
- retcode = call(["ls", "-l"])
+ >>> retcode = subprocess.call(["ls", "-l"])
.. warning::
@@ -206,7 +205,8 @@ This module also defines four shortcut functions:
The arguments are the same as for the Popen constructor. Example::
- check_call(["ls", "-l"])
+ >>> subprocess.check_call(["ls", "-l"])
+ 0
.. warning::
@@ -225,15 +225,15 @@ This module also defines four shortcut functions:
The arguments are the same as for the :class:`Popen` constructor. Example::
>>> subprocess.check_output(["ls", "-l", "/dev/null"])
- 'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
+ b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
The stdout argument is not allowed as it is used internally.
To capture standard error in the result, use ``stderr=subprocess.STDOUT``::
>>> subprocess.check_output(
- ["/bin/sh", "-c", "ls non_existent_file ; exit 0"],
- stderr=subprocess.STDOUT)
- 'ls: non_existent_file: No such file or directory\n'
+ ... ["/bin/sh", "-c", "ls non_existent_file; exit 0"],
+ ... stderr=subprocess.STDOUT)
+ b'ls: non_existent_file: No such file or directory\n'
.. versionadded:: 3.1
@@ -247,7 +247,6 @@ This module also defines four shortcut functions:
stripped from the output. The exit status for the command can be interpreted
according to the rules for the C function :cfunc:`wait`. Example::
- >>> import subprocess
>>> subprocess.getstatusoutput('ls /bin/ls')
(0, '/bin/ls')
>>> subprocess.getstatusoutput('cat /bin/junk')
@@ -264,7 +263,6 @@ This module also defines four shortcut functions:
Like :func:`getstatusoutput`, except the exit status is ignored and the return
value is a string containing the command's output. Example::
- >>> import subprocess
>>> subprocess.getoutput('ls /bin/ls')
'/bin/ls'