summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/2to3.rst10
-rw-r--r--Doc/library/json.rst4
-rw-r--r--Doc/library/optparse.rst27
-rw-r--r--Doc/library/os.rst13
-rw-r--r--Doc/library/platform.rst26
-rw-r--r--Doc/library/site.rst7
-rw-r--r--Doc/library/socket.rst14
7 files changed, 63 insertions, 38 deletions
diff --git a/Doc/library/2to3.rst b/Doc/library/2to3.rst
index 8040124..2e9547c6 100644
--- a/Doc/library/2to3.rst
+++ b/Doc/library/2to3.rst
@@ -74,7 +74,9 @@ warning beneath the diff for a file. You should address the warning in order to
have compliant 3.x code.
2to3 can also refactor doctests. To enable this mode, use the :option:`-d`
-flag. Note that *only* doctests will be refactored.
+flag. Note that *only* doctests will be refactored. This also doesn't require
+the module to be valid Python. For example, doctest like examples in a reST
+document could also be refactored with this option.
The :option:`-v` option enables the output of more information on the
translation process.
@@ -95,4 +97,10 @@ true function call.
.. moduleauthor:: Guido van Rossum
.. moduleauthor:: Collin Winter
+
+.. warning::
+
+ The :mod:`lib2to3` API should be considered unstable and may change
+ drastically in the future.
+
.. XXX What is the public interface anyway?
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index 4eaa690..b67d724 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -370,9 +370,9 @@ Encoders and decoders
def default(self, o):
try:
- iterable = iter(o)
+ iterable = iter(o)
except TypeError:
- pass
+ pass
else:
return list(iterable)
return JSONEncoder.default(self, o)
diff --git a/Doc/library/optparse.rst b/Doc/library/optparse.rst
index de1a116..4936e7d 100644
--- a/Doc/library/optparse.rst
+++ b/Doc/library/optparse.rst
@@ -1193,17 +1193,32 @@ traditional Unix exit status for command-line errors).
Querying and manipulating your option parser
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Sometimes, it's useful to poke around your option parser and see what's there.
-OptionParser provides a couple of methods to help you out:
-
-``has_option(opt_str)``
- Return true if the OptionParser has an option with option string ``opt_str``
- (e.g., ``"-q"`` or ``"--verbose"``).
+The default behavior of the option parser can be customized slightly,
+and you can also poke around your option parser and see what's there.
+OptionParser provides several methods to help you out:
+
+``disable_interspersed_args()``
+ Set parsing to stop on the first non-option. Use this if you have a
+ command processor which runs another command which has options of
+ its own and you want to make sure these options don't get
+ confused. For example, each command might have a different
+ set of options.
+
+``enable_interspersed_args()``
+ Set parsing to not stop on the first non-option, allowing
+ interspersing switches with command arguments. For example,
+ ``"-s arg1 --long arg2"`` would return ``["arg1", "arg2"]``
+ as the command arguments and ``-s, --long`` as options.
+ This is the default behavior.
``get_option(opt_str)``
Returns the Option instance with the option string ``opt_str``, or ``None`` if
no options have that option string.
+``has_option(opt_str)``
+ Return true if the OptionParser has an option with option string ``opt_str``
+ (e.g., ``"-q"`` or ``"--verbose"``).
+
``remove_option(opt_str)``
If the OptionParser has an option corresponding to ``opt_str``, that option is
removed. If that option provided any other option strings, all of those option
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 221596c..9e14003 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -1215,7 +1215,13 @@ to be ignored.
These functions all execute a new program, replacing the current process; they
do not return. On Unix, the new executable is loaded into the current process,
and will have the same process id as the caller. Errors will be reported as
- :exc:`OSError` exceptions.
+ :exc:`OSError` exceptions.
+
+ The current process is replaced immediately. Open file objects and
+ descriptors are not flushed, so if there may be data buffered
+ on these open files, you should flush them using
+ :func:`sys.stdout.flush` or :func:`os.fsync` before calling an
+ :func:`exec\*` function.
The "l" and "v" variants of the :func:`exec\*` functions differ in how
command-line arguments are passed. The "l" variants are perhaps the easiest
@@ -1241,8 +1247,9 @@ to be ignored.
used to define the environment variables for the new process (these are used
instead of the current process' environment); the functions :func:`execl`,
:func:`execlp`, :func:`execv`, and :func:`execvp` all cause the new process to
- inherit the environment of the current process. Availability: Unix,
- Windows.
+ inherit the environment of the current process.
+
+ Availability: Unix, Windows.
.. function:: _exit(n)
diff --git a/Doc/library/platform.rst b/Doc/library/platform.rst
index 22ac72d..3d5228a 100644
--- a/Doc/library/platform.rst
+++ b/Doc/library/platform.rst
@@ -226,29 +226,23 @@ Unix Platforms
.. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...))
- Tries to determine the name of the OS distribution name Returns a tuple
- ``(distname, version, id)`` which defaults to the args given as parameters.
-
- ``supported_dists`` may be given to define the set of Linux
- distributions to look for. It defaults to a list of currently
- supported Linux distributions identified by their release file
- name.
+ This is another name for :func:`linux_distribution`.
.. function:: linux_distribution(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...), full_distribution_name=1)
Tries to determine the name of the Linux OS distribution name.
- ``supported_dists`` may be given to define the set of Linux
- distributions to look for. It defaults to a list of currently
- supported Linux distributions identified by their release file
- name.
+ ``supported_dists`` may be given to define the set of Linux distributions to
+ look for. It defaults to a list of currently supported Linux distributions
+ identified by their release file name.
- If ``full_distribution_name`` is true (default), the full
- distribution read from the OS is returned. Otherwise the short name
- taken from ``supported_dists`` is used.
+ If ``full_distribution_name`` is true (default), the full distribution read
+ from the OS is returned. Otherwise the short name taken from
+ ``supported_dists`` is used.
- Returns a tuple ``(distname,version,id)`` which defaults to the
- args given as parameters.
+ Returns a tuple ``(distname,version,id)`` which defaults to the args given as
+ parameters. ``id`` is the item in parentheses after the version number. It
+ is usually the version codename.
.. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=2048)
diff --git a/Doc/library/site.rst b/Doc/library/site.rst
index 73ec7bf..0fe63a3 100644
--- a/Doc/library/site.rst
+++ b/Doc/library/site.rst
@@ -59,10 +59,11 @@ and :file:`bar.pth` contains::
bar
-Then the following directories are added to ``sys.path``, in this order::
+Then the following version-specific directories are added to
+``sys.path``, in this order::
- /usr/local/lib/python3.0/site-packages/bar
- /usr/local/lib/python3.0/site-packages/foo
+ /usr/local/lib/pythonX.Y/site-packages/bar
+ /usr/local/lib/pythonX.Y/site-packages/foo
Note that :file:`bletch` is omitted because it doesn't exist; the :file:`bar`
directory precedes the :file:`foo` directory because :file:`bar.pth` comes
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index 8f78498..620d08e 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -207,18 +207,18 @@ The module :mod:`socket` exports the following constants and functions:
.. function:: getaddrinfo(host, port[, family[, socktype[, proto[, flags]]]])
Resolves the *host*/*port* argument, into a sequence of 5-tuples that contain
- all the necessary argument for the sockets manipulation. *host* is a domain
- name, a string representation of IPv4/v6 address or ``None``. *port* is a string
- service name (like ``'http'``), a numeric port number or ``None``.
+ all the necessary arguments for creating the corresponding socket. *host* is a domain
+ name, a string representation of an IPv4/v6 address or ``None``. *port* is a string
+ service name such as ``'http'``, a numeric port number or ``None``.
+ The rest of the arguments are optional and must be numeric if specified.
+ By passing ``None`` as the value of *host* and *port*, , you can pass ``NULL`` to the C API.
- The rest of the arguments are optional and must be numeric if specified. For
- *host* and *port*, by passing ``None``, you can pass ``NULL`` to the C API.
The :func:`getaddrinfo` function returns a list of 5-tuples with the following
structure:
``(family, socktype, proto, canonname, sockaddr)``
- *family*, *socktype*, *proto* are all integer and are meant to be passed to the
+ *family*, *socktype*, *proto* are all integers and are meant to be passed to the
:func:`socket` function. *canonname* is a string representing the canonical name
of the *host*. It can be a numeric IPv4/v6 address when :const:`AI_CANONNAME` is
specified for a numeric *host*. *sockaddr* is a tuple describing a socket
@@ -230,7 +230,7 @@ The module :mod:`socket` exports the following constants and functions:
Return a fully qualified domain name for *name*. If *name* is omitted or empty,
it is interpreted as the local host. To find the fully qualified name, the
- hostname returned by :func:`gethostbyaddr` is checked, then aliases for the
+ hostname returned by :func:`gethostbyaddr` is checked, followed by aliases for the
host, if available. The first name which includes a period is selected. In
case no fully qualified domain name is available, the hostname as returned by
:func:`gethostname` is returned.