From 036490d025b768c9e69567c3caac63ccd7a62a09 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 17 May 2009 13:00:36 +0000 Subject: More conversion to new-style optional args. --- Doc/library/fractions.rst | 1 - Doc/library/frameworks.rst | 1 - Doc/library/ftplib.rst | 57 +++++++++++++++--------------- Doc/library/functions.rst | 84 +++++++++++++++++++++++--------------------- Doc/library/functools.rst | 6 ++-- Doc/library/gc.rst | 5 +-- Doc/library/getopt.rst | 23 ++++++------ Doc/library/getpass.rst | 2 +- Doc/library/gettext.rst | 19 +++++----- Doc/library/glob.rst | 1 - Doc/library/grp.rst | 1 - Doc/library/gzip.rst | 4 +-- Doc/library/hashlib.rst | 1 - Doc/library/heapq.rst | 4 +-- Doc/library/hmac.rst | 3 +- Doc/library/http.client.rst | 12 +++---- Doc/library/http.cookies.rst | 10 +++--- Doc/library/http.server.rst | 14 ++++---- Doc/library/i18n.rst | 1 - 19 files changed, 120 insertions(+), 129 deletions(-) diff --git a/Doc/library/fractions.rst b/Doc/library/fractions.rst index c135f91..19d435d 100644 --- a/Doc/library/fractions.rst +++ b/Doc/library/fractions.rst @@ -1,4 +1,3 @@ - :mod:`fractions` --- Rational numbers ===================================== diff --git a/Doc/library/frameworks.rst b/Doc/library/frameworks.rst index 5d8dad5..fe632e0 100644 --- a/Doc/library/frameworks.rst +++ b/Doc/library/frameworks.rst @@ -1,4 +1,3 @@ - .. _frameworks: ****************** diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst index 405a077..ed601a0 100644 --- a/Doc/library/ftplib.rst +++ b/Doc/library/ftplib.rst @@ -36,7 +36,7 @@ Here's a sample session using the :mod:`ftplib` module:: The module defines the following items: -.. class:: FTP([host[, user[, passwd[, acct[, timeout]]]]]) +.. class:: FTP(host='', user='', passwd='', acct=''[, timeout]) Return a new instance of the :class:`FTP` class. When *host* is given, the method call ``connect(host)`` is made. When *user* is given, additionally @@ -46,7 +46,6 @@ The module defines the following items: connection attempt (if is not specified, the global default timeout setting will be used). - .. attribute:: all_errors The set of all exceptions (as a tuple) that methods of :class:`FTP` @@ -56,33 +55,33 @@ The module defines the following items: :exc:`IOError`. - .. exception:: error_reply +.. exception:: error_reply - Exception raised when an unexpected reply is received from the server. + Exception raised when an unexpected reply is received from the server. - .. exception:: error_temp +.. exception:: error_temp - Exception raised when an error code in the range 400--499 is received. + Exception raised when an error code in the range 400--499 is received. - .. exception:: error_perm +.. exception:: error_perm - Exception raised when an error code in the range 500--599 is received. + Exception raised when an error code in the range 500--599 is received. - .. exception:: error_proto +.. exception:: error_proto - Exception raised when a reply is received from the server that does not - begin with a digit in the range 1--5. + Exception raised when a reply is received from the server that does not begin + with a digit in the range 1--5. .. seealso:: Module :mod:`netrc` - Parser for the :file:`.netrc` file format. The file :file:`.netrc` is typically - used by FTP clients to load user authentication information before prompting the - user. + Parser for the :file:`.netrc` file format. The file :file:`.netrc` is + typically used by FTP clients to load user authentication information + before prompting the user. .. index:: single: ftpmirror.py @@ -112,7 +111,7 @@ followed by ``lines`` for the text version or ``binary`` for the binary version. debugging output, logging each line sent and received on the control connection. -.. method:: FTP.connect(host[, port[, timeout]]) +.. method:: FTP.connect(host='', port=0[, timeout]) Connect to the given host and port. The default port number is ``21``, as specified by the FTP protocol specification. It is rarely needed to specify a @@ -133,7 +132,7 @@ followed by ``lines`` for the text version or ``binary`` for the binary version. that may be relevant to the user.) -.. method:: FTP.login([user[, passwd[, acct]]]) +.. method:: FTP.login(user='anonymous', passwd='', acct='') Log in as the given *user*. The *passwd* and *acct* parameters are optional and default to the empty string. If no *user* is specified, it defaults to @@ -150,33 +149,33 @@ followed by ``lines`` for the text version or ``binary`` for the binary version. it's worth a try. -.. method:: FTP.sendcmd(command) +.. method:: FTP.sendcmd(cmd) Send a simple command string to the server and return the response string. -.. method:: FTP.voidcmd(command) +.. method:: FTP.voidcmd(cmd) Send a simple command string to the server and handle the response. Return nothing if a response code in the range 200--299 is received. Raise an exception otherwise. -.. method:: FTP.retrbinary(command, callback[, maxblocksize[, rest]]) +.. method:: FTP.retrbinary(cmd, callback, blocksize=8192, rest=None) - Retrieve a file in binary transfer mode. *command* should be an appropriate + Retrieve a file in binary transfer mode. *cmd* should be an appropriate ``RETR`` command: ``'RETR filename'``. The *callback* function is called for each block of data received, with a single string argument giving the data - block. The optional *maxblocksize* argument specifies the maximum chunk size to + block. The optional *blocksize* argument specifies the maximum chunk size to read on the low-level socket object created to do the actual transfer (which will also be the largest size of the data blocks passed to *callback*). A reasonable default is chosen. *rest* means the same thing as in the :meth:`transfercmd` method. -.. method:: FTP.retrlines(command[, callback]) +.. method:: FTP.retrlines(cmd, callback=None) - Retrieve a file or directory listing in ASCII transfer mode. *command* + Retrieve a file or directory listing in ASCII transfer mode. *cmd* should be an appropriate ``RETR`` command (see :meth:`retrbinary`) or a command such as ``LIST``, ``NLST`` or ``MLSD`` (usually just the string ``'LIST'``). The *callback* function is called for each line, with the @@ -190,9 +189,9 @@ followed by ``lines`` for the text version or ``binary`` for the binary version. Passive mode is on by default. -.. method:: FTP.storbinary(command, file[, blocksize, callback]) +.. method:: FTP.storbinary(cmd, file, blocksize=8192, callback=None) - Store a file in binary transfer mode. *command* should be an appropriate + Store a file in binary transfer mode. *cmd* should be an appropriate ``STOR`` command: ``"STOR filename"``. *file* is an open file object which is read until EOF using its :meth:`read` method in blocks of size *blocksize* to provide the data to be stored. The *blocksize* argument defaults to 8192. @@ -200,16 +199,16 @@ followed by ``lines`` for the text version or ``binary`` for the binary version. on each block of data after it is sent. -.. method:: FTP.storlines(command, file[, callback]) +.. method:: FTP.storlines(cmd, file, callback=None) - Store a file in ASCII transfer mode. *command* should be an appropriate + Store a file in ASCII transfer mode. *cmd* should be an appropriate ``STOR`` command (see :meth:`storbinary`). Lines are read until EOF from the open file object *file* using its :meth:`readline` method to provide the data to be stored. *callback* is an optional single parameter callable that is called on each line after it is sent. -.. method:: FTP.transfercmd(cmd[, rest]) +.. method:: FTP.transfercmd(cmd, rest=None) Initiate a transfer over the data connection. If the transfer is active, send a ``EPRT`` or ``PORT`` command and the transfer command specified by *cmd*, and @@ -229,7 +228,7 @@ followed by ``lines`` for the text version or ``binary`` for the binary version. *rest* argument. -.. method:: FTP.ntransfercmd(cmd[, rest]) +.. method:: FTP.ntransfercmd(cmd, rest=None) Like :meth:`transfercmd`, but returns a tuple of the data connection and the expected size of the data. If the expected size could not be computed, ``None`` diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 23f5214..f0c7195 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -65,14 +65,14 @@ are always available. They are listed here in alphabetical order. .. index:: pair: Boolean; type -.. function:: bytearray([arg[, encoding[, errors]]]) +.. function:: bytearray([source[, encoding[, errors]]]) Return a new array of bytes. The :class:`bytearray` type is a mutable sequence of integers in the range 0 <= x < 256. It has most of the usual methods of mutable sequences, described in :ref:`typesseq-mutable`, as well as most methods that the :class:`str` type has, see :ref:`bytes-methods`. - The optional *arg* parameter can be used to initialize the array in a few + The optional *source* parameter can be used to initialize the array in a few different ways: * If it is a *string*, you must also give the *encoding* (and optionally, @@ -91,7 +91,7 @@ are always available. They are listed here in alphabetical order. Without an argument, an array of size 0 is created. -.. function:: bytes([arg[, encoding[, errors]]]) +.. function:: bytes([source[, encoding[, errors]]]) Return a new "bytes" object, which is an immutable sequence of integers in the range ``0 <= x < 256``. :class:`bytes` is an immutable version of @@ -139,7 +139,7 @@ are always available. They are listed here in alphabetical order. type hierarchy in :ref:`types`. -.. function:: compile(source, filename, mode[, flags[, dont_inherit]]) +.. function:: compile(source, filename, mode, flags=0, dont_inherit=False) Compile the *source* into a code or AST object. Code objects can be executed by an :keyword:`exec` statement or evaluated by a call to :func:`eval`. @@ -263,25 +263,26 @@ are always available. They are listed here in alphabetical order. .. note:: Because :func:`dir` is supplied primarily as a convenience for use at an - interactive prompt, it tries to supply an interesting set of names more than it - tries to supply a rigorously or consistently defined set of names, and its - detailed behavior may change across releases. For example, metaclass attributes - are not in the result list when the argument is a class. + interactive prompt, it tries to supply an interesting set of names more + than it tries to supply a rigorously or consistently defined set of names, + and its detailed behavior may change across releases. For example, + metaclass attributes are not in the result list when the argument is a + class. .. function:: divmod(a, b) Take two (non complex) numbers as arguments and return a pair of numbers - consisting of their quotient and remainder when using integer division. With mixed - operand types, the rules for binary arithmetic operators apply. For integers, - the result is the same as ``(a // b, a % b)``. For floating point - numbers the result is ``(q, a % b)``, where *q* is usually ``math.floor(a / b)`` - but may be 1 less than that. In any case ``q * b + a % b`` is very close to - *a*, if ``a % b`` is non-zero it has the same sign as *b*, and ``0 <= abs(a % b) - < abs(b)``. + consisting of their quotient and remainder when using integer division. With + mixed operand types, the rules for binary arithmetic operators apply. For + integers, the result is the same as ``(a // b, a % b)``. For floating point + numbers the result is ``(q, a % b)``, where *q* is usually ``math.floor(a / + b)`` but may be 1 less than that. In any case ``q * b + a % b`` is very + close to *a*, if ``a % b`` is non-zero it has the same sign as *b*, and ``0 + <= abs(a % b) < abs(b)``. -.. function:: enumerate(iterable[, start=0]) +.. function:: enumerate(iterable, start=0) Return an enumerate object. *iterable* must be a sequence, an :term:`iterator`, or some other object which supports iteration. The @@ -299,7 +300,7 @@ are always available. They are listed here in alphabetical order. 3 Winter -.. function:: eval(expression[, globals[, locals]]) +.. function:: eval(expression, globals=None, locals=None) The arguments are a string and optional globals and locals. If provided, *globals* must be a dictionary. If provided, *locals* can be any mapping @@ -550,18 +551,19 @@ are always available. They are listed here in alphabetical order. case, a :exc:`TypeError` exception is raised. -.. function:: iter(o[, sentinel]) +.. function:: iter(object[, sentinel]) - Return an :term:`iterator` object. The first argument is interpreted very differently - depending on the presence of the second argument. Without a second argument, *o* - must be a collection object which supports the iteration protocol (the - :meth:`__iter__` method), or it must support the sequence protocol (the - :meth:`__getitem__` method with integer arguments starting at ``0``). If it - does not support either of those protocols, :exc:`TypeError` is raised. If the - second argument, *sentinel*, is given, then *o* must be a callable object. The - iterator created in this case will call *o* with no arguments for each call to - its :meth:`__next__` method; if the value returned is equal to *sentinel*, - :exc:`StopIteration` will be raised, otherwise the value will be returned. + Return an :term:`iterator` object. The first argument is interpreted very + differently depending on the presence of the second argument. Without a + second argument, *object* must be a collection object which supports the + iteration protocol (the :meth:`__iter__` method), or it must support the + sequence protocol (the :meth:`__getitem__` method with integer arguments + starting at ``0``). If it does not support either of those protocols, + :exc:`TypeError` is raised. If the second argument, *sentinel*, is given, + then *object* must be a callable object. The iterator created in this case + will call *object* with no arguments for each call to its :meth:`__next__` + method; if the value returned is equal to *sentinel*, :exc:`StopIteration` + will be raised, otherwise the value will be returned. One useful application of the second form of :func:`iter` is to read lines of a file until a certain line is reached. The following example reads a file @@ -584,22 +586,23 @@ are always available. They are listed here in alphabetical order. items. *iterable* may be either a sequence, a container that supports iteration, or an iterator object. If *iterable* is already a list, a copy is made and returned, similar to ``iterable[:]``. For instance, ``list('abc')`` - returns ``['a', 'b', 'c']`` and ``list( (1, 2, 3) )`` returns ``[1, 2, 3]``. If - no argument is given, returns a new empty list, ``[]``. + returns ``['a', 'b', 'c']`` and ``list( (1, 2, 3) )`` returns ``[1, 2, 3]``. + If no argument is given, returns a new empty list, ``[]``. :class:`list` is a mutable sequence type, as documented in :ref:`typesseq`. + .. function:: locals() Update and return a dictionary representing the current local symbol table. .. note:: - The contents of this dictionary should not be modified; changes may not affect - the values of local variables used by the interpreter. + The contents of this dictionary should not be modified; changes may not + affect the values of local variables used by the interpreter. - Free variables are returned by :func:`locals` when it is called in a function block. - Modifications of free variables may not affect the values used by the + Free variables are returned by :func:`locals` when it is called in a function + block. Modifications of free variables may not affect the values used by the interpreter. Free variables are not returned in class blocks. @@ -666,7 +669,7 @@ are always available. They are listed here in alphabetical order. :meth:`__index__` method that returns an integer. -.. function:: open(file[, mode='r'[, buffering=None[, encoding=None[, errors=None[, newline=None[, closefd=True]]]]]]) +.. function:: open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, closefd=True) Open *file* and return a corresponding stream. If the file cannot be opened, an :exc:`IOError` is raised. @@ -812,7 +815,7 @@ are always available. They are listed here in alphabetical order. must be of integer types, and *y* must be non-negative. -.. function:: print([object, ...][, sep=' '][, end='\\n'][, file=sys.stdout]) +.. function:: print([object, ...], *, sep=' ', end='\\n', file=sys.stdout) Print *object*\(s) to the stream *file*, separated by *sep* and followed by *end*. *sep*, *end* and *file*, if present, must be given as keyword @@ -828,7 +831,7 @@ are always available. They are listed here in alphabetical order. is not present or ``None``, :data:`sys.stdout` will be used. -.. function:: property([fget[, fset[, fdel[, doc]]]]) +.. function:: property(fget=None, fset=None, fdel=None, doc=None) Return a property attribute. @@ -987,7 +990,7 @@ are always available. They are listed here in alphabetical order. for an alternate version that returns an iterator. -.. function:: sorted(iterable[, key[, reverse]]) +.. function:: sorted(iterable[, key][, reverse]) Return a new sorted list from the items in *iterable*. @@ -1103,7 +1106,8 @@ are always available. They are listed here in alphabetical order. class C(B): def method(self, arg): - super().method(arg) # This does the same thing as: super(C, self).method(arg) + super().method(arg) # This does the same thing as: + # super(C, self).method(arg) Note that :func:`super` is implemented as part of the binding process for explicit dotted attribute lookups such as ``super().__getitem__(name)``. @@ -1209,7 +1213,7 @@ are always available. They are listed here in alphabetical order. True -.. function:: __import__(name[, globals[, locals[, fromlist[, level]]]]) +.. function:: __import__(name, globals={}, locals={}, fromlist=[], level=-1) .. index:: statement: import diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index 6fd3cf9..94be636 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -15,7 +15,7 @@ function for the purposes of this module. The :mod:`functools` module defines the following functions: -.. function:: partial(func[,*args][, **keywords]) +.. function:: partial(func, *args, **keywords) Return a new :class:`partial` object which when called will behave like *func* called with the positional arguments *args* and keyword arguments *keywords*. If @@ -58,7 +58,7 @@ The :mod:`functools` module defines the following functions: *sequence* contains only one item, the first item is returned. -.. function:: update_wrapper(wrapper, wrapped[, assigned][, updated]) +.. function:: update_wrapper(wrapper, wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES) Update a *wrapper* function to look like the *wrapped* function. The optional arguments are tuples to specify which attributes of the original function are @@ -77,7 +77,7 @@ The :mod:`functools` module defines the following functions: than helpful. -.. function:: wraps(wrapped[, assigned][, updated]) +.. function:: wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES) This is a convenience function for invoking ``partial(update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated)`` as a function decorator diff --git a/Doc/library/gc.rst b/Doc/library/gc.rst index 9092145..34aba65 100644 --- a/Doc/library/gc.rst +++ b/Doc/library/gc.rst @@ -1,4 +1,3 @@ - :mod:`gc` --- Garbage Collector interface ========================================= @@ -37,7 +36,7 @@ The :mod:`gc` module provides the following functions: Returns true if automatic collection is enabled. -.. function:: collect([generation]) +.. function:: collect(generations=2) With no arguments, run a full collection. The optional argument *generation* may be an integer specifying which generation to collect (from 0 to 2). A @@ -210,5 +209,3 @@ The following constants are provided for use with :func:`set_debug`: The debugging flags necessary for the collector to print information about a leaking program (equal to ``DEBUG_COLLECTABLE | DEBUG_UNCOLLECTABLE | DEBUG_SAVEALL``). - -.. rubric:: Footnotes diff --git a/Doc/library/getopt.rst b/Doc/library/getopt.rst index 94ba90e..7f6b670 100644 --- a/Doc/library/getopt.rst +++ b/Doc/library/getopt.rst @@ -1,10 +1,9 @@ - :mod:`getopt` --- Parser for command line options ================================================= .. module:: getopt - :synopsis: Portable parser for command line options; support both short and long option - names. + :synopsis: Portable parser for command line options; support both short and + long option names. This module helps scripts to parse the command line arguments in ``sys.argv``. @@ -20,27 +19,27 @@ This module provides two functions and an exception: -.. function:: getopt(args, options[, long_options]) +.. function:: getopt(args, shortopts, longopts=[]) Parses command line options and parameter list. *args* is the argument list to be parsed, without the leading reference to the running program. Typically, this - means ``sys.argv[1:]``. *options* is the string of option letters that the + means ``sys.argv[1:]``. *shortopts* is the string of option letters that the script wants to recognize, with options that require an argument followed by a colon (``':'``; i.e., the same format that Unix :cfunc:`getopt` uses). .. note:: - Unlike GNU :cfunc:`getopt`, after a non-option argument, all further arguments - are considered also non-options. This is similar to the way non-GNU Unix systems - work. + Unlike GNU :cfunc:`getopt`, after a non-option argument, all further + arguments are considered also non-options. This is similar to the way + non-GNU Unix systems work. - *long_options*, if specified, must be a list of strings with the names of the + *longopts*, if specified, must be a list of strings with the names of the long options which should be supported. The leading ``'--'`` characters should not be included in the option name. Long options which require an argument should be followed by an equal sign (``'='``). To accept only long - options, *options* should be an empty string. Long options on the command line + options, *shortopts* should be an empty string. Long options on the command line can be recognized so long as they provide a prefix of the option name that - matches exactly one of the accepted options. For example, if *long_options* is + matches exactly one of the accepted options. For example, if *longopts* is ``['foo', 'frob']``, the option :option:`--fo` will match as :option:`--foo`, but :option:`--f` will not match uniquely, so :exc:`GetoptError` will be raised. @@ -55,7 +54,7 @@ exception: allowing multiple occurrences. Long and short options may be mixed. -.. function:: gnu_getopt(args, options[, long_options]) +.. function:: gnu_getopt(args, shortopts, longopts=[]) This function works like :func:`getopt`, except that GNU style scanning mode is used by default. This means that option and non-option arguments may be diff --git a/Doc/library/getpass.rst b/Doc/library/getpass.rst index ff1c091..ffe2b12 100644 --- a/Doc/library/getpass.rst +++ b/Doc/library/getpass.rst @@ -10,7 +10,7 @@ The :mod:`getpass` module provides two functions: -.. function:: getpass([prompt[, stream]]) +.. function:: getpass(prompt='Password: ', stream=None) Prompt the user for a password without echoing. The user is prompted using the string *prompt*, which defaults to ``'Password: '``. On Unix, the prompt diff --git a/Doc/library/gettext.rst b/Doc/library/gettext.rst index a295c0e..015b889 100644 --- a/Doc/library/gettext.rst +++ b/Doc/library/gettext.rst @@ -1,4 +1,3 @@ - :mod:`gettext` --- Multilingual internationalization services ============================================================= @@ -31,7 +30,7 @@ application needs to switch languages on the fly, you probably want to use the class-based API instead. -.. function:: bindtextdomain(domain[, localedir]) +.. function:: bindtextdomain(domain, localedir=None) Bind the *domain* to the locale directory *localedir*. More concretely, :mod:`gettext` will look for binary :file:`.mo` files for the given domain using @@ -43,14 +42,14 @@ class-based API instead. returned. [#]_ -.. function:: bind_textdomain_codeset(domain[, codeset]) +.. function:: bind_textdomain_codeset(domain, codeset=None) Bind the *domain* to *codeset*, changing the encoding of strings returned by the :func:`gettext` family of functions. If *codeset* is omitted, then the current binding is returned. -.. function:: textdomain([domain]) +.. function:: textdomain(domain=None) Change or query the current global domain. If *domain* is ``None``, then the current global domain is returned, otherwise the global domain is set to @@ -141,7 +140,7 @@ class can also install themselves in the built-in namespace as the function :func:`_`. -.. function:: find(domain[, localedir[, languages[, all]]]) +.. function:: find(domain, localedir=None, languages=None, all=False) This function implements the standard :file:`.mo` file search algorithm. It takes a *domain*, identical to what :func:`textdomain` takes. Optional @@ -159,7 +158,7 @@ class can also install themselves in the built-in namespace as the function :func:`find` then expands and normalizes the languages, and then iterates through them, searching for an existing file built of these components: - :file:`localedir/language/LC_MESSAGES/domain.mo` + :file:`{localedir}/{language}/LC_MESSAGES/{domain}.mo` The first such file name that exists is returned by :func:`find`. If no such file is found, then ``None`` is returned. If *all* is given, it returns a list @@ -167,7 +166,7 @@ class can also install themselves in the built-in namespace as the function the environment variables. -.. function:: translation(domain[, localedir[, languages[, class_[, fallback[, codeset]]]]]) +.. function:: translation(domain, localedir=None, languages=None, class_=None, fallback=False, codeset=None) Return a :class:`Translations` instance based on the *domain*, *localedir*, and *languages*, which are first passed to :func:`find` to get a list of the @@ -188,7 +187,7 @@ class can also install themselves in the built-in namespace as the function :class:`NullTranslations` instance if *fallback* is true. -.. function:: install(domain[, localedir[, codeset[, names]]]]) +.. function:: install(domain, localedir=None, codeset=None, names=None) This installs the function :func:`_` in Python's builtin namespace, based on *domain*, *localedir*, and *codeset* which are passed to the function @@ -218,7 +217,7 @@ interface you can use to write your own specialized translation classes. Here are the methods of :class:`NullTranslations`: -.. class:: NullTranslations([fp]) +.. class:: NullTranslations(fp=None) Takes an optional file object *fp*, which is ignored by the base class. Initializes "protected" instance variables *_info* and *_charset* which are set @@ -289,7 +288,7 @@ are the methods of :class:`NullTranslations`: encoding used to return translated messages. - .. method:: install([names]) + .. method:: install(names=None) This method installs :meth:`self.gettext` into the built-in namespace, binding it to ``_``. diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst index b87a826..3e0322d 100644 --- a/Doc/library/glob.rst +++ b/Doc/library/glob.rst @@ -1,4 +1,3 @@ - :mod:`glob` --- Unix style pathname pattern expansion ===================================================== diff --git a/Doc/library/grp.rst b/Doc/library/grp.rst index a71c308..57f160a 100644 --- a/Doc/library/grp.rst +++ b/Doc/library/grp.rst @@ -1,4 +1,3 @@ - :mod:`grp` --- The group database ================================= diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst index 818de6a..1f64428 100644 --- a/Doc/library/gzip.rst +++ b/Doc/library/gzip.rst @@ -24,7 +24,7 @@ For other archive formats, see the :mod:`bz2`, :mod:`zipfile`, and The module defines the following items: -.. class:: GzipFile([filename[, mode[, compresslevel[, fileobj[, mtime]]]]]) +.. class:: GzipFile(filename=None, mode=None, compresslevel=9, fileobj=None, mtime=None) Constructor for the :class:`GzipFile` class, which simulates most of the methods of a file object, with the exception of the :meth:`readinto` and @@ -73,7 +73,7 @@ The module defines the following items: Support for the :keyword:`with` statement was added. -.. function:: open(filename[, mode[, compresslevel]]) +.. function:: open(filename, mode='rb', compresslevel=9) This is a shorthand for ``GzipFile(filename,`` ``mode,`` ``compresslevel)``. The *filename* argument is required; *mode* defaults to ``'rb'`` and diff --git a/Doc/library/hashlib.rst b/Doc/library/hashlib.rst index 69facce..f63d957 100644 --- a/Doc/library/hashlib.rst +++ b/Doc/library/hashlib.rst @@ -1,4 +1,3 @@ - :mod:`hashlib` --- Secure hashes and message digests ==================================================== diff --git a/Doc/library/heapq.rst b/Doc/library/heapq.rst index 4a18e02..6acb283 100644 --- a/Doc/library/heapq.rst +++ b/Doc/library/heapq.rst @@ -115,7 +115,7 @@ The module also offers three general purpose functions based on heaps. streams is already sorted (smallest to largest). -.. function:: nlargest(n, iterable[, key]) +.. function:: nlargest(n, iterable, key=None) Return a list with the *n* largest elements from the dataset defined by *iterable*. *key*, if provided, specifies a function of one argument that is @@ -124,7 +124,7 @@ The module also offers three general purpose functions based on heaps. reverse=True)[:n]`` -.. function:: nsmallest(n, iterable[, key]) +.. function:: nsmallest(n, iterable, key=None) Return a list with the *n* smallest elements from the dataset defined by *iterable*. *key*, if provided, specifies a function of one argument that is diff --git a/Doc/library/hmac.rst b/Doc/library/hmac.rst index 0abe421..faaedf4 100644 --- a/Doc/library/hmac.rst +++ b/Doc/library/hmac.rst @@ -1,4 +1,3 @@ - :mod:`hmac` --- Keyed-Hashing for Message Authentication ======================================================== @@ -11,7 +10,7 @@ This module implements the HMAC algorithm as described by :rfc:`2104`. -.. function:: new(key[, msg[, digestmod]]) +.. function:: new(key, msg=None, digestmod=None) Return a new hmac object. If *msg* is present, the method call ``update(msg)`` is made. *digestmod* is the digest constructor or module for the HMAC object to diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst index 8ecd7c7..8362948 100644 --- a/Doc/library/http.client.rst +++ b/Doc/library/http.client.rst @@ -23,7 +23,7 @@ HTTPS protocols. It is normally not used directly --- the module The module provides the following classes: -.. class:: HTTPConnection(host[, port[, strict[, timeout]]]) +.. class:: HTTPConnection(host, port=None, strict=None[, timeout]) An :class:`HTTPConnection` instance represents one transaction with an HTTP server. It should be instantiated passing it a host and optional port @@ -45,7 +45,7 @@ The module provides the following classes: >>> h3 = http.client.HTTPConnection('www.cwi.nl', 80, timeout=10) -.. class:: HTTPSConnection(host[, port[, key_file[, cert_file[, strict[, timeout]]]]]) +.. class:: HTTPSConnection(host, port=None, key_file=None, cert_file=None, strict=None[, timeout]) A subclass of :class:`HTTPConnection` that uses SSL for communication with secure servers. Default port is ``443``. *key_file* is the name of a PEM @@ -57,7 +57,7 @@ The module provides the following classes: This does not do any certificate verification. -.. class:: HTTPResponse(sock[, debuglevel=0][, strict=0]) +.. class:: HTTPResponse(sock, debuglevel=0, strict=0, method=None, url=None) Class whose instances are returned upon successful connection. Not instantiated directly by user. @@ -349,7 +349,7 @@ HTTPConnection Objects :class:`HTTPConnection` instances have the following methods: -.. method:: HTTPConnection.request(method, url[, body[, headers]]) +.. method:: HTTPConnection.request(method, url, body=None, headers={}) This will send a request to the server using the HTTP request method *method* and the selector *url*. If the *body* argument is @@ -398,7 +398,7 @@ As an alternative to using the :meth:`request` method described above, you can also send your request step by step, by using the four functions below. -.. method:: HTTPConnection.putrequest(request, selector[, skip_host[, skip_accept_encoding]]) +.. method:: HTTPConnection.putrequest(request, selector, skip_host=False, skip_accept_encoding=False) This should be the first call after the connection to the server has been made. It sends a line to the server consisting of the *request* string, the *selector* @@ -444,7 +444,7 @@ statement. Reads and returns the response body, or up to the next *amt* bytes. -.. method:: HTTPResponse.getheader(name[, default]) +.. method:: HTTPResponse.getheader(name, default=None) Get the contents of the header *name*, or *default* if there is no matching header. diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst index 7470c61..0151e94 100644 --- a/Doc/library/http.cookies.rst +++ b/Doc/library/http.cookies.rst @@ -78,7 +78,7 @@ Cookie Objects :meth:`value_decode` are inverses on the range of *value_decode*. -.. method:: BaseCookie.output([attrs[, header[, sep]]]) +.. method:: BaseCookie.output(attrs=None, header='Set-Cookie:', sep='\\r\\n') Return a string representation suitable to be sent as HTTP headers. *attrs* and *header* are sent to each :class:`Morsel`'s :meth:`output` method. *sep* is used @@ -86,7 +86,7 @@ Cookie Objects (CRLF). -.. method:: BaseCookie.js_output([attrs]) +.. method:: BaseCookie.js_output(attrs=None) Return an embeddable JavaScript snippet, which, if run on a browser which supports JavaScript, will act the same as if the HTTP headers was sent. @@ -157,7 +157,7 @@ Morsel Objects Whether *K* is a member of the set of keys of a :class:`Morsel`. -.. method:: Morsel.output([attrs[, header]]) +.. method:: Morsel.output(attrs=None, header='Set-Cookie:') Return a string representation of the Morsel, suitable to be sent as an HTTP header. By default, all the attributes are included, unless *attrs* is given, in @@ -165,7 +165,7 @@ Morsel Objects ``"Set-Cookie:"``. -.. method:: Morsel.js_output([attrs]) +.. method:: Morsel.js_output(attrs=None) Return an embeddable JavaScript snippet, which, if run on a browser which supports JavaScript, will act the same as if the HTTP header was sent. @@ -173,7 +173,7 @@ Morsel Objects The meaning for *attrs* is the same as in :meth:`output`. -.. method:: Morsel.OutputString([attrs]) +.. method:: Morsel.OutputString(attrs=None) Return a string representing the Morsel, without any surrounding HTTP or JavaScript. diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst index cad28dd..d647980 100644 --- a/Doc/library/http.server.rst +++ b/Doc/library/http.server.rst @@ -155,14 +155,14 @@ of which this module provides three different variants: This method will parse and dispatch the request to the appropriate :meth:`do_\*` method. You should never need to override it. - .. method:: send_error(code[, message]) + .. method:: send_error(code, message=None) Sends and logs a complete error reply to the client. The numeric *code* specifies the HTTP error code, with *message* as optional, more specific text. A complete set of headers is sent, followed by text composed using the :attr:`error_message_format` class variable. - .. method:: send_response(code[, message]) + .. method:: send_response(code, message=None) Sends a response header and logs the accepted request. The HTTP response line is sent, followed by *Server* and *Date* headers. The values for @@ -179,7 +179,7 @@ of which this module provides three different variants: Sends a blank line, indicating the end of the HTTP headers in the response. - .. method:: log_request([code[, size]]) + .. method:: log_request(code='-', size='-') Logs an accepted (successful) request. *code* should specify the numeric HTTP code associated with the response. If a size of the response is @@ -205,11 +205,11 @@ of which this module provides three different variants: Returns the server software's version string. This is a combination of the :attr:`server_version` and :attr:`sys_version` class variables. - .. method:: date_time_string([timestamp]) + .. method:: date_time_string(timestamp=None) - Returns the date and time given by *timestamp* (which must be in the - format returned by :func:`time.time`), formatted for a message header. If - *timestamp* is omitted, it uses the current date and time. + Returns the date and time given by *timestamp* (which must be None or in + the format returned by :func:`time.time`), formatted for a message + header. If *timestamp* is omitted, it uses the current date and time. The result looks like ``'Sun, 06 Nov 1994 08:49:37 GMT'``. diff --git a/Doc/library/i18n.rst b/Doc/library/i18n.rst index 8e57102..818f129 100644 --- a/Doc/library/i18n.rst +++ b/Doc/library/i18n.rst @@ -1,4 +1,3 @@ - .. _i18n: ******************** -- cgit v0.12