diff --git a/Doc/c-api/conversion.rst b/Doc/c-api/conversion.rst index b32100b..07b21d5 100644 --- a/Doc/c-api/conversion.rst +++ b/Doc/c-api/conversion.rst @@ -55,7 +55,7 @@ The following functions provide locale-independent string to number conversions. Convert a string ``s`` to a :ctype:`double`, raising a Python exception on failure. The set of accepted strings corresponds to - the set of strings accepted by Python's :func:`float` constructor, + the set of strings accepted by Python's :class:`float` constructor, except that ``s`` must not have leading or trailing whitespace. The conversion is independent of the current locale. diff --git a/Doc/c-api/file.rst b/Doc/c-api/file.rst index bdb8c49..32e571d 100644 --- a/Doc/c-api/file.rst +++ b/Doc/c-api/file.rst @@ -167,7 +167,7 @@ change in future releases of Python. .. index:: single: Py_PRINT_RAW Write object *obj* to file object *p*. The only supported flag for *flags* is - :const:`Py_PRINT_RAW`; if given, the :func:`str` of the object is written + :const:`Py_PRINT_RAW`; if given, the :class:`str` of the object is written instead of the :func:`repr`. Return ``0`` on success or ``-1`` on failure; the appropriate exception will be set. diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst index 295fb90..e2c49db 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -97,7 +97,7 @@ Floating Point Objects .. cfunction:: void PyFloat_AsString(char *buf, PyFloatObject *v) Convert the argument *v* to a string, using the same rules as - :func:`str`. The length of *buf* should be at least 100. + :class:`str`. The length of *buf* should be at least 100. This function is unsafe to call because it writes to a buffer whose length it does not know. diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst index 6a538b3..e935817 100644 --- a/Doc/c-api/object.rst +++ b/Doc/c-api/object.rst @@ -10,7 +10,7 @@ Object Protocol Print an object *o*, on file *fp*. Returns ``-1`` on error. The flags argument is used to enable certain printing options. The only option currently supported - is :const:`Py_PRINT_RAW`; if given, the :func:`str` of the object is written + is :const:`Py_PRINT_RAW`; if given, the :class:`str` of the object is written instead of the :func:`repr`. @@ -146,7 +146,7 @@ Object Protocol Compute a string representation of object *o*. Returns the string representation on success, *NULL* on failure. This is the equivalent of the - Python expression ``str(o)``. Called by the :func:`str` built-in function and + Python expression ``str(o)``. Called by the :class:`str` built-in function and by the :keyword:`print` statement. @@ -164,7 +164,7 @@ Object Protocol Compute a Unicode string representation of object *o*. Returns the Unicode string representation on success, *NULL* on failure. This is the equivalent of - the Python expression ``unicode(o)``. Called by the :func:`unicode` built-in + the Python expression ``unicode(o)``. Called by the :class:`unicode` built-in function. diff --git a/Doc/c-api/string.rst b/Doc/c-api/string.rst index 9b95859..396b6f7 100644 --- a/Doc/c-api/string.rst +++ b/Doc/c-api/string.rst @@ -277,7 +277,7 @@ called with a non-string parameter. Create an object by decoding *size* bytes of the encoded buffer *s* using the codec registered for *encoding*. *encoding* and *errors* have the same meaning - as the parameters of the same name in the :func:`unicode` built-in function. + as the parameters of the same name in the :class:`unicode` built-in function. The codec to be used is looked up using the Python codec registry. Return *NULL* if an exception was raised by the codec. diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index 5be88ac..91b018a 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -190,7 +190,7 @@ method. The method will be passed the type object as the first parameter rather than an instance of the type. This is used to create *class methods*, - similar to what is created when using the :func:`classmethod` built-in + similar to what is created when using the :class:`classmethod` built-in function. .. versionadded:: 2.3 diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index 9af4cfc..cd17372 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -358,7 +358,7 @@ type objects) *must* have the :attr:`ob_size` field. .. cmember:: reprfunc PyTypeObject.tp_str An optional pointer to a function that implements the built-in operation - :func:`str`. (Note that :class:`str` is a type now, and :func:`str` calls the + :class:`str`. (Note that :class:`str` is a type now, and :class:`str` calls the constructor for that type. This constructor calls :cfunc:`PyObject_Str` to do the actual work, and :cfunc:`PyObject_Str` will call this handler.) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 964d2c8..74c92dd 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -409,7 +409,7 @@ these codecs are directly usable via the following functions. Many of the following APIs take two arguments encoding and errors. These parameters encoding and errors have the same semantics as the ones of the -built-in :func:`unicode` Unicode object constructor. +built-in :class:`unicode` Unicode object constructor. Setting encoding to *NULL* causes the default encoding to be used which is ASCII. The file system calls should use :cdata:`Py_FileSystemDefaultEncoding` @@ -435,7 +435,7 @@ These are the generic codec APIs: Create a Unicode object by decoding *size* bytes of the encoded string *s*. *encoding* and *errors* have the same meaning as the parameters of the same name - in the :func:`unicode` built-in function. The codec to be used is looked up + in the :class:`unicode` built-in function. The codec to be used is looked up using the Python codec registry. Return *NULL* if an exception was raised by the codec. diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst index fb2c15a..ff54e4a 100644 --- a/Doc/extending/newtypes.rst +++ b/Doc/extending/newtypes.rst @@ -1025,8 +1025,8 @@ Object Presentation In Python, there are three ways to generate a textual representation of an object: the :func:`repr` function (or equivalent back-tick syntax), the -:func:`str` function, and the :keyword:`print` statement. For most objects, the -:keyword:`print` statement is equivalent to the :func:`str` function, but it is +:class:`str` function, and the :keyword:`print` statement. For most objects, the +:keyword:`print` statement is equivalent to the :class:`str` function, but it is possible to special-case printing to a :ctype:`FILE\*` if necessary; this should only be done if efficiency is identified as a problem and profiling suggests that creating a temporary string object to be written to a file is too @@ -1054,9 +1054,9 @@ If no :attr:`tp_repr` handler is specified, the interpreter will supply a representation that uses the type's :attr:`tp_name` and a uniquely-identifying value for the object. -The :attr:`tp_str` handler is to :func:`str` what the :attr:`tp_repr` handler +The :attr:`tp_str` handler is to :class:`str` what the :attr:`tp_repr` handler described above is to :func:`repr`; that is, it is called when Python code calls -:func:`str` on an instance of your object. Its implementation is very similar +:class:`str` on an instance of your object. Its implementation is very similar to the :attr:`tp_repr` function, but the resulting string is intended for human consumption. If :attr:`tp_str` is not specified, the :attr:`tp_repr` handler is used instead. diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index e53facd..eb1363b 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -824,8 +824,8 @@ bite. How do I convert a string to a number? -------------------------------------- -For integers, use the built-in :func:`int` type constructor, e.g. ``int('144') -== 144``. Similarly, :func:`float` converts to floating-point, +For integers, use the built-in :class:`int` type constructor, e.g. ``int('144') +== 144``. Similarly, :class:`float` converts to floating-point, e.g. ``float('144') == 144.0``. By default, these interpret the number as decimal, so that ``int('0144') == @@ -850,7 +850,7 @@ How do I convert a number to a string? -------------------------------------- To convert, e.g., the number 144 to the string '144', use the built-in type -constructor :func:`str`. If you want a hexadecimal or octal representation, use +constructor :class:`str`. If you want a hexadecimal or octal representation, use the built-in functions :func:`hex` or :func:`oct`. For fancy formatting, see the :ref:`formatstrings` section, e.g. ``"{:04d}".format(144)`` yields ``'0144'`` and ``"{:.3f}".format(1/3)`` yields ``'0.333'``. You may also use @@ -975,8 +975,8 @@ Not as such. For simple input parsing, the easiest approach is usually to split the line into whitespace-delimited words using the :meth:`~str.split` method of string objects -and then convert decimal strings to numeric values using :func:`int` or -:func:`float`. ``split()`` supports an optional "sep" parameter which is useful +and then convert decimal strings to numeric values using :class:`int` or +:class:`float`. ``split()`` supports an optional "sep" parameter which is useful if the line uses something other than whitespace as a separator. For more complicated input parsing, regular expressions are more powerful @@ -1035,7 +1035,7 @@ iterable) into a tuple with the same items in the same order. For example, ``tuple([1, 2, 3])`` yields ``(1, 2, 3)`` and ``tuple('abc')`` yields ``('a', 'b', 'c')``. If the argument is a tuple, it does not make a copy -but returns the same object, so it is cheap to call :func:`tuple` when you +but returns the same object, so it is cheap to call :class:`tuple` when you aren't sure that an object is already a tuple. The type constructor ``list(seq)`` converts any sequence or iterable into a list diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 7822634..2b312dc 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -114,7 +114,7 @@ Glossary decorator A function returning another function, usually applied as a function transformation using the ``@wrapper`` syntax. Common examples for - decorators are :func:`classmethod` and :func:`staticmethod`. + decorators are :class:`classmethod` and :func:`staticmethod`. The decorator syntax is merely syntactic sugar, the following two function definitions are semantically equivalent:: @@ -162,7 +162,7 @@ Glossary called or used ("If it looks like a duck and quacks like a duck, it must be a duck.") By emphasizing interfaces rather than specific types, well-designed code improves its flexibility by allowing polymorphic - substitution. Duck-typing avoids tests using :func:`type` or + substitution. Duck-typing avoids tests using :class:`type` or :func:`isinstance`. (Note, however, that duck-typing can be complemented with :term:`abstract base class`\ es.) Instead, it typically employs :func:`hasattr` tests or :term:`EAFP` programming. diff --git a/Doc/howto/cporting.rst b/Doc/howto/cporting.rst index 8030f13..d209bca 100644 --- a/Doc/howto/cporting.rst +++ b/Doc/howto/cporting.rst @@ -11,7 +11,7 @@ Porting Extension Modules to 3.0 Although changing the C-API was not one of Python 3.0's objectives, the many Python level changes made leaving 2.x's API intact impossible. In fact, some - changes such as :func:`int` and :func:`long` unification are more obvious on + changes such as :class:`int` and :class:`long` unification are more obvious on the C level. This document endeavors to document incompatibilities and how they can be worked around. @@ -41,9 +41,9 @@ str/unicode Unification ----------------------- -Python 3.0's :func:`str` (``PyString_*`` functions in C) type is equivalent to -2.x's :func:`unicode` (``PyUnicode_*``). The old 8-bit string type has become -:func:`bytes`. Python 2.6 and later provide a compatibility header, +Python 3.0's :class:`str` (``PyString_*`` functions in C) type is equivalent to +2.x's :class:`unicode` (``PyUnicode_*``). The old 8-bit string type has become +:class:`bytes`. Python 2.6 and later provide a compatibility header, :file:`bytesobject.h`, mapping ``PyBytes`` names to ``PyString`` ones. For best compatibility with 3.0, :ctype:`PyUnicode` should be used for textual data and :ctype:`PyBytes` for binary data. It's also important to remember that @@ -92,8 +92,8 @@ and :ctype:`PyBytes`. :: long/int Unification -------------------- -In Python 3.0, there is only one integer type. It is called :func:`int` on the -Python level, but actually corresponds to 2.x's :func:`long` type. In the +In Python 3.0, there is only one integer type. It is called :class:`int` on the +Python level, but actually corresponds to 2.x's :class:`long` type. In the C-API, ``PyInt_*`` functions are replaced by their ``PyLong_*`` neighbors. The best course of action here is using the ``PyInt_*`` functions aliased to ``PyLong_*`` found in :file:`intobject.h`. The abstract ``PyNumber_*`` APIs diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index 55a1d62..a8a0109 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -414,7 +414,7 @@ Now a new dictionary of unique keys can be constructed like this:: {'a': None, 'r': None, 'b': None, 'c': None, 'd': None} Using the non-data descriptor protocol, a pure Python version of -:func:`classmethod` would look like this:: +:class:`classmethod` would look like this:: class ClassMethod(object): "Emulate PyClassMethod_Type() in Objects/funcobject.c" diff --git a/Doc/howto/doanddont.rst b/Doc/howto/doanddont.rst index 2e9e0b8..e075f3d 100644 --- a/Doc/howto/doanddont.rst +++ b/Doc/howto/doanddont.rst @@ -294,8 +294,8 @@ with a series of multiply operations:: >>> reduce(operator.mul, range(1, n+1)) 24 -When it comes to parsing numbers, note that :func:`float`, :func:`int` and -:func:`long` all accept string arguments and will reject ill-formed strings +When it comes to parsing numbers, note that :class:`float`, :class:`int` and +:class:`long` all accept string arguments and will reject ill-formed strings by raising an :exc:`ValueError`. diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index 4ae216a..6e5cd45 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -223,8 +223,8 @@ These two statements are equivalent:: for i in obj: print i -Iterators can be materialized as lists or tuples by using the :func:`list` or -:func:`tuple` constructor functions: +Iterators can be materialized as lists or tuples by using the :class:`list` or +:class:`tuple` constructor functions: >>> L = [1,2,3] >>> iterator = iter(L) @@ -297,7 +297,7 @@ have methods that return other iterators. If you want to iterate over keys, values, or key/value pairs, you can explicitly call the ``iterkeys()``, ``itervalues()``, or ``iteritems()`` methods to get an appropriate iterator. -The :func:`dict` constructor can accept an iterator that returns a finite stream +The :class:`dict` constructor can accept an iterator that returns a finite stream of ``(key, value)`` tuples: >>> L = [('Italy', 'Rome'), ('France', 'Paris'), ('US', 'Washington DC')] diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst index ff3c721..179bb4f 100644 --- a/Doc/howto/unicode.rst +++ b/Doc/howto/unicode.rst @@ -242,7 +242,7 @@ therefore check if a value is a string type with ``isinstance(value, basestring)``. Under the hood, Python represents Unicode strings as either 16- or 32-bit integers, depending on how the Python interpreter was compiled. -The :func:`unicode` constructor has the signature ``unicode(string[, encoding, +The :class:`unicode` constructor has the signature ``unicode(string[, encoding, errors])``. All of its arguments should be 8-bit strings. The first argument is converted to Unicode using the specified encoding; if you leave off the ``encoding`` argument, the ASCII encoding is used for the conversion, so diff --git a/Doc/library/2to3.rst b/Doc/library/2to3.rst index de31251..62967e1 100644 --- a/Doc/library/2to3.rst +++ b/Doc/library/2to3.rst @@ -342,7 +342,7 @@ and off individually. They are described here in more detail. .. 2to3fixer:: xrange - Renames :func:`xrange` to :func:`range` and wraps existing :func:`range` + Renames :class:`xrange` to :func:`range` and wraps existing :func:`range` calls with :class:`list`. .. 2to3fixer:: xreadlines diff --git a/Doc/library/_winreg.rst b/Doc/library/_winreg.rst index 825ce1f..4f32ae9 100644 --- a/Doc/library/_winreg.rst +++ b/Doc/library/_winreg.rst @@ -676,7 +676,7 @@ The object also support comparison semantics, so handle objects will compare true if they both reference the same underlying Windows handle value. Handle objects can be converted to an integer (e.g., using the built-in -:func:`int` function), in which case the underlying Windows handle value is +:class:`int` function), in which case the underlying Windows handle value is returned. You can also use the :meth:`~PyHKEY.Detach` method to return the integer handle, and also disconnect the Windows handle from the handle object. diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index 48cac2f..6fba0bf 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -523,10 +523,10 @@ languages): [('i', 4), ('p', 2), ('s', 4), ('m', 1)] When a letter is first encountered, it is missing from the mapping, so the -:attr:`default_factory` function calls :func:`int` to supply a default count of +:attr:`default_factory` function calls :class:`int` to supply a default count of zero. The increment operation then builds up the count for each letter. -The function :func:`int` which always returns zero is just a special case of +The function :class:`int` which always returns zero is just a special case of constant functions. A faster and more flexible way to create constant functions is to use :func:`itertools.repeat` which can supply any constant value (not just zero): diff --git a/Doc/library/cookie.rst b/Doc/library/cookie.rst index 3bdc61a..34e7fda 100644 --- a/Doc/library/cookie.rst +++ b/Doc/library/cookie.rst @@ -47,7 +47,7 @@ result, the parsing rules used are a bit less strict. .. class:: SimpleCookie([input]) This class derives from :class:`BaseCookie` and overrides :meth:`value_decode` - and :meth:`value_encode` to be the identity and :func:`str` respectively. + and :meth:`value_encode` to be the identity and :class:`str` respectively. .. class:: SerialCookie([input]) diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index f4e9d7c..baf65b0 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -111,7 +111,7 @@ The :mod:`csv` module defines the following functions: value :const:`None` is written as the empty string. While this isn't a reversible transformation, it makes it easier to dump SQL NULL data values to CSV files without preprocessing the data returned from a ``cursor.fetch*`` call. - All other non-string data are stringified with :func:`str` before being written. + All other non-string data are stringified with :class:`str` before being written. A short usage example:: @@ -399,7 +399,7 @@ Writer Objects :class:`Writer` objects (:class:`DictWriter` instances and objects returned by the :func:`writer` function) have the following public methods. A *row* must be a sequence of strings or numbers for :class:`Writer` objects and a dictionary -mapping fieldnames to strings or numbers (by passing them through :func:`str` +mapping fieldnames to strings or numbers (by passing them through :class:`str` first) for :class:`DictWriter` objects. Note that complex numbers are written out surrounded by parens. This may cause some problems for other programs which read CSV files (assuming they support complex numbers at all). diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 9addfe7..8b7b95a 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -828,7 +828,7 @@ the more significant byte last. Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, ``slice(TOS1, TOS)`` is pushed; if it is 3, ``slice(TOS2, TOS1, TOS)`` is - pushed. See the :func:`slice` built-in function for more information. + pushed. See the :class:`slice` built-in function for more information. .. opcode:: EXTENDED_ARG (ext) diff --git a/Doc/library/email.charset.rst b/Doc/library/email.charset.rst index b008386..a7bb473 100644 --- a/Doc/library/email.charset.rst +++ b/Doc/library/email.charset.rst @@ -248,6 +248,6 @@ new entries to the global character set, alias, and codec registries: Add a codec that map characters in the given character set to and from Unicode. *charset* is the canonical name of a character set. *codecname* is the name of a - Python codec, as appropriate for the second argument to the :func:`unicode` + Python codec, as appropriate for the second argument to the :class:`unicode` built-in, or to the :meth:`encode` method of a Unicode string. diff --git a/Doc/library/email.header.rst b/Doc/library/email.header.rst index fe09de5..ce980fd 100644 --- a/Doc/library/email.header.rst +++ b/Doc/library/email.header.rst @@ -102,7 +102,7 @@ Here is the :class:`Header` class description: ``us-ascii``, the *charset* hint, ``utf-8``. The first character set to not provoke a :exc:`UnicodeError` is used. - Optional *errors* is passed through to any :func:`unicode` or + Optional *errors* is passed through to any :class:`unicode` or :func:`ustr.encode` call, and defaults to "strict". @@ -125,7 +125,7 @@ Here is the :class:`Header` class description: .. method:: __unicode__() - A helper for the built-in :func:`unicode` function. Returns the header as + A helper for the built-in :class:`unicode` function. Returns the header as a Unicode string. diff --git a/Doc/library/email.util.rst b/Doc/library/email.util.rst index 153ba78..aebb975 100644 --- a/Doc/library/email.util.rst +++ b/Doc/library/email.util.rst @@ -133,7 +133,7 @@ There are several useful utilities provided in the :mod:`email.utils` module: :meth:`Message.get_param` may return a 3-tuple containing the character set, language, and value. :func:`collapse_rfc2231_value` turns this into a unicode string. Optional *errors* is passed to the *errors* argument of the built-in - :func:`unicode` function; it defaults to ``replace``. Optional + :class:`unicode` function; it defaults to ``replace``. Optional *fallback_charset* specifies the character set to use if the one in the :rfc:`2231` header is not known by Python; it defaults to ``us-ascii``. diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index 8bd903a..5ec36e5 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -50,7 +50,7 @@ The following exceptions are only used as base classes for other exceptions. The base class for all built-in exceptions. It is not meant to be directly inherited by user-defined classes (for that, use :exc:`Exception`). If - :func:`str` or :func:`unicode` is called on an instance of this class, the + :class:`str` or :class:`unicode` is called on an instance of this class, the representation of the argument(s) to the instance are returned, or the empty string when there were no arguments. @@ -308,7 +308,7 @@ The following exceptions are the exceptions that are actually raised. script or standard input (also interactively). Instances of this class have attributes :attr:`filename`, :attr:`lineno`, - :attr:`offset` and :attr:`text` for easier access to the details. :func:`str` + :attr:`offset` and :attr:`text` for easier access to the details. :class:`str` of the exception instance returns only the message. diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 4b63c9f..47c3271 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -11,20 +11,20 @@ available. They are listed here in alphabetical order. .. .. Built-in Functions .. .. =================== ================= ================== ================= ==================== :func:`abs` :func:`divmod` :func:`input` :func:`open` :func:`staticmethod` -:func:`all` :func:`enumerate` :func:`int` :func:`ord` :func:`str` +:func:`all` :func:`enumerate` :class:`int` :func:`ord` :class:`str` :func:`any` :func:`eval` :func:`isinstance` :func:`pow` :func:`sum` -:func:`basestring` :func:`execfile` :func:`issubclass` :func:`print` :func:`super` -:func:`bin` :func:`file` :func:`iter` :func:`property` :func:`tuple` -:func:`bool` :func:`filter` :func:`len` :func:`range` :func:`type` -:func:`bytearray` :func:`float` :func:`list` :func:`raw_input` :func:`unichr` -:func:`callable` :func:`format` :func:`locals` :func:`reduce` :func:`unicode` -:func:`chr` :func:`frozenset` :func:`long` :func:`reload` :func:`vars` -:func:`classmethod` :func:`getattr` :func:`map` :func:`repr` :func:`xrange` +:class:`basestring` :func:`execfile` :func:`issubclass` :func:`print` :func:`super` +:func:`bin` :class:`file` :func:`iter` :func:`property` :class:`tuple` +:class:`bool` :func:`filter` :func:`len` :func:`range` :class:`type` +:class:`bytearray` :class:`float` :class:`list` :func:`raw_input` :func:`unichr` +:func:`callable` :func:`format` :func:`locals` :func:`reduce` :class:`unicode` +:func:`chr` :class:`frozenset` :class:`long` :func:`reload` :func:`vars` +:class:`classmethod` :func:`getattr` :func:`map` :func:`repr` :class:`xrange` :func:`cmp` :func:`globals` :func:`max` :func:`reversed` :func:`zip` -:func:`compile` :func:`hasattr` :func:`memoryview` :func:`round` :func:`__import__` -:func:`complex` :func:`hash` :func:`min` :func:`set` :func:`apply` -:func:`delattr` :func:`help` :func:`next` :func:`setattr` :func:`buffer` -:func:`dict` :func:`hex` :func:`object` :func:`slice` :func:`coerce` +:func:`compile` :func:`hasattr` :class:`memoryview` :func:`round` :func:`__import__` +:class:`complex` :func:`hash` :func:`min` :class:`set` :func:`apply` +:func:`delattr` :func:`help` :func:`next` :func:`setattr` :class:`buffer` +:class:`dict` :func:`hex` :class:`object` :class:`slice` :func:`coerce` :func:`dir` :func:`id` :func:`oct` :func:`sorted` :func:`intern` =================== ================= ================== ================= ==================== @@ -63,7 +63,7 @@ available. They are listed here in alphabetical order. .. versionadded:: 2.5 -.. function:: basestring() +.. class:: basestring() This abstract type is the superclass for :class:`str` and :class:`unicode`. It cannot be called or instantiated, but it can be used to test whether an object @@ -82,7 +82,7 @@ available. They are listed here in alphabetical order. .. versionadded:: 2.6 -.. function:: bool([x]) +.. class:: bool([x]) Convert a value to a Boolean, using the standard truth testing procedure. If *x* is false or omitted, this returns :const:`False`; otherwise it returns @@ -98,7 +98,7 @@ available. They are listed here in alphabetical order. If no argument is given, this function returns :const:`False`. -.. function:: bytearray([source[, encoding[, errors]]]) +.. class:: 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 @@ -109,7 +109,7 @@ available. They are listed here in alphabetical order. different ways: * If it is a *string*, you must also give the *encoding* (and optionally, - *errors*) parameters; :func:`bytearray` then converts the string to + *errors*) parameters; :class:`bytearray` then converts the string to bytes using :meth:`str.encode`. * If it is an *integer*, the array will have that size and will be @@ -143,7 +143,7 @@ available. They are listed here in alphabetical order. also :func:`unichr`. -.. function:: classmethod(function) +.. class:: classmethod(function) Return a class method for *function*. @@ -235,15 +235,15 @@ available. They are listed here in alphabetical order. does not have to end in a newline anymore. -.. function:: complex([real[, imag]]) +.. class:: complex([real[, imag]]) Create a complex number with the value *real* + *imag*\*j or convert a string or number to a complex number. If the first parameter is a string, it will be interpreted as a complex number and the function must be called without a second parameter. The second parameter can never be a string. Each argument may be any numeric type (including complex). If *imag* is omitted, it defaults to zero and - the function serves as a numeric conversion function like :func:`int`, - :func:`long` and :func:`float`. If both arguments are omitted, returns ``0j``. + the function serves as a numeric conversion function like :class:`int`, + :class:`long` and :class:`float`. If both arguments are omitted, returns ``0j``. The complex type is described in :ref:`typesnumeric`. @@ -256,7 +256,7 @@ available. They are listed here in alphabetical order. example, ``delattr(x, 'foobar')`` is equivalent to ``del x.foobar``. -.. function:: dict([arg]) +.. class:: dict([arg]) :noindex: Create a new data dictionary, optionally with items taken from *arg*. @@ -425,7 +425,7 @@ available. They are listed here in alphabetical order. used reliably to modify a function's locals. -.. function:: file(filename[, mode[, bufsize]]) +.. class:: file(filename[, mode[, bufsize]]) Constructor function for the :class:`file` type, described further in section :ref:`bltin-file-objects`. The constructor's arguments are the same as those @@ -456,7 +456,7 @@ available. They are listed here in alphabetical order. where the *function* returns false. -.. function:: float([x]) +.. class:: float([x]) Convert a string or a number to floating point. If the argument is a string, it must contain a possibly signed decimal or floating point number, possibly @@ -500,7 +500,7 @@ available. They are listed here in alphabetical order. .. versionadded:: 2.6 -.. function:: frozenset([iterable]) +.. class:: frozenset([iterable]) :noindex: Return a frozenset object, optionally with elements taken from *iterable*. @@ -600,7 +600,7 @@ available. They are listed here in alphabetical order. Consider using the :func:`raw_input` function for general input from users. -.. function:: int([x[, base]]) +.. class:: int([x[, base]]) Convert a string or number to a plain integer. If the argument is a string, it must contain a possibly signed decimal number representable as a Python @@ -675,7 +675,7 @@ available. They are listed here in alphabetical order. sequence (string, tuple or list) or a mapping (dictionary). -.. function:: list([iterable]) +.. class:: list([iterable]) Return a list whose items are the same and in the same order as *iterable*'s items. *iterable* may be either a sequence, a container that supports @@ -701,12 +701,12 @@ available. They are listed here in alphabetical order. affect the values of local and free variables used by the interpreter. -.. function:: long([x[, base]]) +.. class:: long([x[, base]]) Convert a string or number to a long integer. If the argument is a string, it must contain a possibly signed number of arbitrary size, possibly embedded in whitespace. The *base* argument is interpreted in the same way as for - :func:`int`, and may only be given when *x* is a string. Otherwise, the argument + :class:`int`, and may only be given when *x* is a string. Otherwise, the argument may be a plain or long integer or a floating point number, and a long integer with the same value is returned. Conversion of floating point numbers to integers truncates (towards zero). If no arguments are given, returns ``0L``. @@ -741,7 +741,7 @@ available. They are listed here in alphabetical order. Added support for the optional *key* argument. -.. function:: memoryview(obj) +.. class:: memoryview(obj) :noindex: Return a "memory view" object created from the given argument. See @@ -771,7 +771,7 @@ available. They are listed here in alphabetical order. .. versionadded:: 2.6 -.. function:: object() +.. class:: object() Return a new featureless object. :class:`object` is a base for all new style classes. It has the methods that are common to all instances of new style @@ -895,7 +895,7 @@ available. They are listed here in alphabetical order. *end*. *sep*, *end* and *file*, if present, must be given as keyword arguments. - All non-keyword arguments are converted to strings like :func:`str` does and + All non-keyword arguments are converted to strings like :class:`str` does and written to the stream, separated by *sep* and followed by *end*. Both *sep* and *end* must be strings; they can also be ``None``, which means to use the default values. If no *object* is given, :func:`print` will just write @@ -1155,7 +1155,7 @@ available. They are listed here in alphabetical order. can't be represented exactly as a float. See :ref:`tut-fp-issues` for more information. -.. function:: set([iterable]) +.. class:: set([iterable]) :noindex: Return a new set, optionally with elements taken from *iterable*. @@ -1176,7 +1176,7 @@ available. They are listed here in alphabetical order. ``x.foobar = 123``. -.. function:: slice([start,] stop[, step]) +.. class:: slice([start,] stop[, step]) .. index:: single: Numerical Python @@ -1242,7 +1242,7 @@ available. They are listed here in alphabetical order. as ``C().f()``). The instance is ignored except for its class. Static methods in Python are similar to those found in Java or C++. For a more - advanced concept, see :func:`classmethod` in this section. + advanced concept, see :class:`classmethod` in this section. For more information on static methods, consult the documentation on the standard type hierarchy in :ref:`types`. @@ -1253,7 +1253,7 @@ available. They are listed here in alphabetical order. Function decorator syntax added. -.. function:: str([object]) +.. class:: str([object]) Return a string containing a nicely printable representation of an object. For strings, this returns the string itself. The difference with ``repr(object)`` @@ -1266,7 +1266,7 @@ available. They are listed here in alphabetical order. described in the :ref:`string-methods` section. To output formatted strings use template strings or the ``%`` operator described in the :ref:`string-formatting` section. In addition see the :ref:`stringservices` - section. See also :func:`unicode`. + section. See also :class:`unicode`. .. function:: sum(iterable[, start]) @@ -1338,7 +1338,7 @@ available. They are listed here in alphabetical order. .. versionadded:: 2.2 -.. function:: tuple([iterable]) +.. class:: tuple([iterable]) Return a tuple whose items are the same and in the same order as *iterable*'s items. *iterable* may be a sequence, a container that supports iteration, or an @@ -1352,7 +1352,7 @@ available. They are listed here in alphabetical order. :class:`list`, and :class:`set` classes, and the :mod:`collections` module. -.. function:: type(object) +.. class:: type(object) .. index:: object: type @@ -1360,10 +1360,10 @@ available. They are listed here in alphabetical order. :func:`isinstance` built-in function is recommended for testing the type of an object. - With three arguments, :func:`type` functions as a constructor as detailed below. + With three arguments, :class:`type` functions as a constructor as detailed below. -.. function:: type(name, bases, dict) +.. class:: type(name, bases, dict) :noindex: Return a new type object. This is essentially a dynamic form of the @@ -1394,7 +1394,7 @@ available. They are listed here in alphabetical order. .. versionadded:: 2.0 -.. function:: unicode([object[, encoding [, errors]]]) +.. class:: unicode([object[, encoding [, errors]]]) Return the Unicode string version of *object* using one of the following modes: @@ -1424,7 +1424,7 @@ available. They are listed here in alphabetical order. string-specific methods described in the :ref:`string-methods` section. To output formatted strings use template strings or the ``%`` operator described in the :ref:`string-formatting` section. In addition see the - :ref:`stringservices` section. See also :func:`str`. + :ref:`stringservices` section. See also :class:`str`. .. versionadded:: 2.0 @@ -1445,20 +1445,20 @@ available. They are listed here in alphabetical order. the effects on the corresponding symbol table are undefined. [#]_ -.. function:: xrange([start,] stop[, step]) +.. class:: xrange([start,] stop[, step]) This function is very similar to :func:`range`, but returns an "xrange object" instead of a list. This is an opaque sequence type which yields the same values as the corresponding list, without actually storing them all simultaneously. - The advantage of :func:`xrange` over :func:`range` is minimal (since - :func:`xrange` still has to create the values when asked for them) except when a + The advantage of :class:`xrange` over :func:`range` is minimal (since + :class:`xrange` still has to create the values when asked for them) except when a very large range is used on a memory-starved machine or when all of the range's elements are never used (such as when the loop is usually terminated with :keyword:`break`). .. impl-detail:: - :func:`xrange` is intended to be simple and fast. Implementations may + :class:`xrange` is intended to be simple and fast. Implementations may impose restrictions to achieve this. The C implementation of Python restricts all arguments to native C longs ("short" Python integers), and also requires that the number of elements fit in a native C long. If a @@ -1608,7 +1608,7 @@ bypass these functions without concerns about missing something important. Use the extended call syntax with ``*args`` and ``**keywords`` instead. -.. function:: buffer(object[, offset[, size]]) +.. class:: buffer(object[, offset[, size]]) The *object* argument must be an object that supports the buffer call interface (such as strings, arrays, and buffers). A new buffer object will be created diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index 787c000..d49e52e 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -95,7 +95,7 @@ The :mod:`functools` module defines the following functions: The :func:`partial` is used for partial function application which "freezes" some portion of a function's arguments and/or keywords resulting in a new object with a simplified signature. For example, :func:`partial` can be used to create - a callable that behaves like the :func:`int` function where the *base* argument + a callable that behaves like the :class:`int` function where the *base* argument defaults to two: >>> from functools import partial diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index b7f407d..f72f830 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -638,7 +638,7 @@ loops that truncate the stream. This itertool may require significant auxiliary storage (depending on how much temporary data needs to be stored). In general, if one iterator uses most or all of the data before another iterator starts, it is faster to use - :func:`list` instead of :func:`tee`. + :class:`list` instead of :func:`tee`. .. versionadded:: 2.4 diff --git a/Doc/library/locale.rst b/Doc/library/locale.rst index 85dad99..9c44de8 100644 --- a/Doc/library/locale.rst +++ b/Doc/library/locale.rst @@ -401,7 +401,7 @@ The :mod:`locale` module defines the following exception and functions: .. versionadded:: 2.5 -.. function:: str(float) +.. class:: str(float) Formats a floating point number using the same format as the built-in function ``str(float)``, but takes the decimal point into account. diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst index 4feae2d..85d78f0 100644 --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -2784,7 +2784,7 @@ wire). Returns the message for this :class:`LogRecord` instance after merging any user-supplied arguments with the message. If the user-supplied message - argument to the logging call is not a string, :func:`str` is called on it to + argument to the logging call is not a string, :class:`str` is called on it to convert it to a string. This allows use of user-defined classes as messages, whose ``__str__`` method can return the actual format string to be used. diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index 26d0b3d..b0a9e32 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -1440,7 +1440,7 @@ referent can: >>> l[2:5] [4, 9, 16] -Notice that applying :func:`str` to a proxy will return the representation of +Notice that applying :class:`str` to a proxy will return the representation of the referent, whereas applying :func:`repr` will return the representation of the proxy. diff --git a/Doc/library/numbers.rst b/Doc/library/numbers.rst index a0a825f..da9921b 100644 --- a/Doc/library/numbers.rst +++ b/Doc/library/numbers.rst @@ -51,7 +51,7 @@ The numeric tower :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``, ``%``, ``<``, ``<=``, ``>``, and ``>=``. - Real also provides defaults for :func:`complex`, :attr:`~Complex.real`, + Real also provides defaults for :class:`complex`, :attr:`~Complex.real`, :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`. @@ -60,7 +60,7 @@ The numeric tower Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and :attr:`~Rational.denominator` properties, which should be in lowest terms. With these, it provides a default for - :func:`float`. + :class:`float`. .. attribute:: numerator @@ -74,7 +74,7 @@ The numeric tower .. class:: Integral Subtypes :class:`Rational` and adds a conversion to :class:`int`. - Provides defaults for :func:`float`, :attr:`~Rational.numerator`, and + Provides defaults for :class:`float`, :attr:`~Rational.numerator`, and :attr:`~Rational.denominator`, and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``. diff --git a/Doc/library/optparse.rst b/Doc/library/optparse.rst index d4b121b..473fcff 100644 --- a/Doc/library/optparse.rst +++ b/Doc/library/optparse.rst @@ -550,7 +550,7 @@ help message: .. versionadded:: 2.4 Options that have a default value can include ``%default`` in the help - string---\ :mod:`optparse` will replace it with :func:`str` of the option's + string---\ :mod:`optparse` will replace it with :class:`str` of the option's default value. If an option has no default value (or the default value is ``None``), ``%default`` expands to ``none``. @@ -1282,12 +1282,12 @@ Integer arguments (type ``"int"`` or ``"long"``) are parsed as follows: * otherwise, the number is parsed as a decimal number -The conversion is done by calling either :func:`int` or :func:`long` with the +The conversion is done by calling either :class:`int` or :class:`long` with the appropriate base (2, 8, 10, or 16). If this fails, so will :mod:`optparse`, although with a more useful error message. ``"float"`` and ``"complex"`` option arguments are converted directly with -:func:`float` and :func:`complex`, with similar error-handling. +:class:`float` and :class:`complex`, with similar error-handling. ``"choice"`` options are a subtype of ``"string"`` options. The :attr:`~Option.choices` option attribute (a sequence of strings) defines the diff --git a/Doc/library/parser.rst b/Doc/library/parser.rst index c46aeae..ae248a9 100644 --- a/Doc/library/parser.rst +++ b/Doc/library/parser.rst @@ -154,7 +154,7 @@ and ``'exec'`` forms. symbols in the input tree. -.. function:: tuple2st(sequence) +.. class:: tuple2st(sequence) This is the same function as :func:`sequence2st`. This entry point is maintained for backward compatibility. diff --git a/Doc/library/random.rst b/Doc/library/random.rst index 4306911..11ad396 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -176,7 +176,7 @@ Functions for sequences: Members of the population need not be :term:`hashable` or unique. If the population contains repeats, then each occurrence is a possible selection in the sample. - To choose a sample from a range of integers, use an :func:`xrange` object as an + To choose a sample from a range of integers, use an :class:`xrange` object as an argument. This is especially fast and space efficient for sampling from a large population: ``sample(xrange(10000000), 60)``. diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 96152f9..9cdd0a8 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -658,7 +658,7 @@ correspond to Unix system calls applicable to sockets. file object and socket object may be closed or garbage-collected independently. The socket must be in blocking mode (it can not have a timeout). The optional *mode* and *bufsize* arguments are interpreted the same way as by the built-in - :func:`file` function. + :class:`file` function. .. note:: diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index da5db1d..891fc9d 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -27,7 +27,7 @@ instances and exceptions. Some operations are supported by several object types; in particular, practically all objects can be compared, tested for truth value, and converted to a string (with the :func:`repr` function or the slightly different -:func:`str` function). The latter function is implicitly used when an object is +:class:`str` function). The latter function is implicitly used when an object is written by the :func:`print` function. @@ -277,8 +277,8 @@ Python fully supports mixed arithmetic: when a binary arithmetic operator has operands of different numeric types, the operand with the "narrower" type is widened to that of the other, where plain integer is narrower than long integer is narrower than floating point is narrower than complex. Comparisons between -numbers of mixed type use the same rule. [#]_ The constructors :func:`int`, -:func:`long`, :func:`float`, and :func:`complex` can be used to produce numbers +numbers of mixed type use the same rule. [#]_ The constructors :class:`int`, +:class:`long`, :class:`float`, and :class:`complex` can be used to produce numbers of a specific type. All built-in numeric types support the following operations. See @@ -351,7 +351,7 @@ Notes: single: trunc() (in module math) pair: numeric; conversions - Conversion from floats using :func:`int` or :func:`long` truncates toward + Conversion from floats using :class:`int` or :class:`long` truncates toward zero like the related function, :func:`math.trunc`. Use the function :func:`math.floor` to round downward and :func:`math.ceil` to round upward. @@ -691,14 +691,14 @@ brackets), with or without enclosing parentheses, but an empty tuple must have the enclosing parentheses, such as ``a, b, c`` or ``()``. A single item tuple must have a trailing comma, such as ``(d,)``. -Bytearray objects are created with the built-in function :func:`bytearray`. +Bytearray objects are created with the built-in function :class:`bytearray`. Buffer objects are not directly supported by Python syntax, but can be created -by calling the built-in function :func:`buffer`. They don't support +by calling the built-in function :class:`buffer`. They don't support concatenation or repetition. Objects of type xrange are similar to buffers in that there is no specific syntax to -create them, but they are created using the :func:`xrange` function. They don't +create them, but they are created using the :class:`xrange` function. They don't support slicing, concatenation or repetition, and using ``in``, ``not in``, :func:`min` or :func:`max` on them is inefficient. @@ -1426,7 +1426,7 @@ The conversion types are: | | :func:`repr`). | | +------------+-----------------------------------------------------+-------+ | ``'s'`` | String (converts any Python object using | \(6) | -| | :func:`str`). | | +| | :class:`str`). | | +------------+-----------------------------------------------------+-------+ | ``'%'`` | No argument is converted, results in a ``'%'`` | | | | character in the result. | | @@ -2889,7 +2889,7 @@ Type Objects module: types Type objects represent the various object types. An object's type is accessed -by the built-in function :func:`type`. There are no special operations on +by the built-in function :class:`type`. There are no special operations on types. The standard module :mod:`types` defines names for all standard built-in types. @@ -2927,7 +2927,7 @@ Boolean values are the two constant objects ``False`` and ``True``. They are used to represent truth values (although other values can also be considered false or true). In numeric contexts (for example when used as the argument to an arithmetic operator), they behave like the integers 0 and 1, respectively. -The built-in function :func:`bool` can be used to cast any value to a Boolean, +The built-in function :class:`bool` can be used to cast any value to a Boolean, if the value can be interpreted as a truth value (see section Truth Value Testing above). diff --git a/Doc/library/string.rst b/Doc/library/string.rst index 59ac116..9cf265e 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -275,7 +275,7 @@ as a string, overriding its own definition of formatting. By converting the value to a string before calling :meth:`__format__`, the normal formatting logic is bypassed. -Two conversion flags are currently supported: ``'!s'`` which calls :func:`str` +Two conversion flags are currently supported: ``'!s'`` which calls :class:`str` on the value, and ``'!r'`` which calls :func:`repr`. Some examples:: @@ -315,7 +315,7 @@ Most built-in types implement the following options for format specifications, although some of the formatting options are only supported by the numeric types. A general convention is that an empty format string (``""``) produces -the same result as if you had called :func:`str` on the value. A +the same result as if you had called :class:`str` on the value. A non-empty format string typically modifies the result. The general form of a *standard format specifier* is: @@ -442,7 +442,7 @@ The available integer presentation types are: In addition to the above presentation types, integers can be formatted with the floating point presentation types listed below (except -``'n'`` and None). When doing so, :func:`float` is used to convert the +``'n'`` and None). When doing so, :class:`float` is used to convert the integer to a floating point number before formatting. The available presentation types for floating point and decimal values are: @@ -799,14 +799,14 @@ not be removed until Python 3.0. The functions defined in this module are: .. function:: atof(s) .. deprecated:: 2.0 - Use the :func:`float` built-in function. + Use the :class:`float` built-in function. .. index:: builtin: float Convert a string to a floating point number. The string must have the standard syntax for a floating point literal in Python, optionally preceded by a sign (``+`` or ``-``). Note that this behaves identical to the built-in function - :func:`float` when passed a string. + :class:`float` when passed a string. .. note:: @@ -823,7 +823,7 @@ not be removed until Python 3.0. The functions defined in this module are: .. function:: atoi(s[, base]) .. deprecated:: 2.0 - Use the :func:`int` built-in function. + Use the :class:`int` built-in function. .. index:: builtin: eval @@ -833,7 +833,7 @@ not be removed until Python 3.0. The functions defined in this module are: leading characters of the string (after stripping the sign): ``0x`` or ``0X`` means 16, ``0`` means 8, anything else means 10. If *base* is 16, a leading ``0x`` or ``0X`` is always accepted, though not required. This behaves - identically to the built-in function :func:`int` when passed a string. (Also + identically to the built-in function :class:`int` when passed a string. (Also note: for a more flexible interpretation of numeric literals, use the built-in function :func:`eval`.) @@ -841,7 +841,7 @@ not be removed until Python 3.0. The functions defined in this module are: .. function:: atol(s[, base]) .. deprecated:: 2.0 - Use the :func:`long` built-in function. + Use the :class:`long` built-in function. .. index:: builtin: long @@ -850,7 +850,7 @@ not be removed until Python 3.0. The functions defined in this module are: The *base* argument has the same meaning as for :func:`atoi`. A trailing ``l`` or ``L`` is not allowed, except if the base is 0. Note that when invoked without *base* or with *base* set to 10, this behaves identical to the built-in - function :func:`long` when passed a string. + function :class:`long` when passed a string. .. function:: capitalize(word) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 12f861b..b5c5f11 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -739,7 +739,7 @@ always available. Strings specifying the primary and secondary prompt of the interpreter. These are only defined if the interpreter is in interactive mode. Their initial values in this case are ``'>>> '`` and ``'... '``. If a non-string object is - assigned to either variable, its :func:`str` is re-evaluated each time the + assigned to either variable, its :class:`str` is re-evaluated each time the interpreter prepares to read a new interactive command; this can be used to implement a dynamic prompt. diff --git a/Doc/library/types.rst b/Doc/library/types.rst index 637704b..c48e671 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -22,8 +22,8 @@ argument types, like the following:: else: mylist.remove(item) -Starting in Python 2.2, built-in factory functions such as :func:`int` and -:func:`str` are also names for the corresponding types. This is now the +Starting in Python 2.2, built-in factory functions such as :class:`int` and +:class:`str` are also names for the corresponding types. This is now the preferred way to access the type instead of using the :mod:`types` module. Accordingly, the example above should be written as follows:: @@ -45,7 +45,7 @@ The module defines the following names: .. index:: builtin: type - The type of type objects (such as returned by :func:`type`); alias of the + The type of type objects (such as returned by :class:`type`); alias of the built-in :class:`type`. @@ -180,7 +180,7 @@ The module defines the following names: .. index:: builtin: xrange - The type of range objects returned by :func:`xrange`; alias of the built-in + The type of range objects returned by :class:`xrange`; alias of the built-in :class:`xrange`. @@ -188,7 +188,7 @@ The module defines the following names: .. index:: builtin: slice - The type of objects returned by :func:`slice`; alias of the built-in + The type of objects returned by :class:`slice`; alias of the built-in :class:`slice`. @@ -212,7 +212,7 @@ The module defines the following names: .. index:: builtin: buffer - The type of buffer objects created by the :func:`buffer` function. + The type of buffer objects created by the :class:`buffer` function. .. data:: DictProxyType diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst index 42ae8e2..c8b49cb 100644 --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -732,7 +732,7 @@ Test cases A class method called before tests in an individual class run. ``setUpClass`` is called with the class as the only argument - and must be decorated as a :func:`classmethod`:: + and must be decorated as a :class:`classmethod`:: @classmethod def setUpClass(cls): diff --git a/Doc/library/userdict.rst b/Doc/library/userdict.rst index ab9ab04..4998008 100644 --- a/Doc/library/userdict.rst +++ b/Doc/library/userdict.rst @@ -176,7 +176,7 @@ The :mod:`UserString` module defines the following classes: instance's contents are initially set to a copy of *sequence*. *sequence* can be either a regular Python string or Unicode string, an instance of :class:`UserString` (or a subclass) or an arbitrary sequence which can be - converted into a string using the built-in :func:`str` function. + converted into a string using the built-in :class:`str` function. .. note:: The :class:`UserString` class has been moved to the :mod:`collections` diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 7c2c9af..7292183 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -36,7 +36,7 @@ memory. The ':keyword:`is`' operator compares the identity of two objects; the implemented as its address). An object's :dfn:`type` is also unchangeable. [#]_ An object's type determines the operations that the object supports (e.g., "does it have a length?") and also defines the possible values for objects of that -type. The :func:`type` function returns an object's type (which is an object +type. The :class:`type` function returns an object's type (which is an object itself). The *value* of some objects can change. Objects whose value can change are said to be *mutable*; objects whose value is unchangeable once they are created are called *immutable*. (The value of an immutable container object @@ -337,7 +337,7 @@ Sequences :func:`ord` convert between code units and nonnegative integers representing the Unicode ordinals as defined in the Unicode Standard 3.0. Conversion from and to other encodings are possible through the Unicode method :meth:`encode` and the - built-in function :func:`unicode`. + built-in function :class:`unicode`. Tuples .. index:: @@ -378,7 +378,7 @@ Sequences .. index:: bytearray A bytearray object is a mutable array. They are created by the built-in - :func:`bytearray` constructor. Aside from being mutable (and hence + :class:`bytearray` constructor. Aside from being mutable (and hence unhashable), byte arrays otherwise provide the same interface and functionality as immutable bytes objects. @@ -409,7 +409,7 @@ Set types Sets .. index:: object: set - These represent a mutable set. They are created by the built-in :func:`set` + These represent a mutable set. They are created by the built-in :class:`set` constructor and can be modified afterwards by several methods, such as :meth:`add`. @@ -417,7 +417,7 @@ Set types .. index:: object: frozenset These represent an immutable set. They are created by the built-in - :func:`frozenset` constructor. As a frozenset is immutable and + :class:`frozenset` constructor. As a frozenset is immutable and :term:`hashable`, it can be used again as an element of another set, or as a dictionary key. @@ -1061,7 +1061,7 @@ Internal types Slice objects are used to represent slices when *extended slice syntax* is used. This is a slice using two colons, or multiple slices or ellipses separated by commas, e.g., ``a[i:j:step]``, ``a[i:j, k:l]``, or ``a[..., i:j]``. They are - also created by the built-in :func:`slice` function. + also created by the built-in :class:`slice` function. .. index:: single: start (slice object attribute) @@ -1101,7 +1101,7 @@ Internal types object that alters the way in which that object is retrieved from classes and class instances. The behaviour of class method objects upon such retrieval is described above, under "User-defined methods". Class method objects are created - by the built-in :func:`classmethod` constructor. + by the built-in :class:`classmethod` constructor. .. _newstyle: @@ -1133,7 +1133,7 @@ For compatibility reasons, classes are still old-style by default. New-style classes are created by specifying another new-style class (i.e. a type) as a parent class, or the "top-level type" :class:`object` if no other parent is needed. The behaviour of new-style classes differs from that of old-style -classes in a number of important details in addition to what :func:`type` +classes in a number of important details in addition to what :class:`type` returns. Some of these changes are fundamental to the new object model, like the way special methods are invoked. Others are "fixes" that could not be implemented before for compatibility concerns, like the method resolution order @@ -1313,7 +1313,7 @@ Basic customization builtin: str statement: print - Called by the :func:`str` built-in function and by the :keyword:`print` + Called by the :class:`str` built-in function and by the :keyword:`print` statement to compute the "informal" string representation of an object. This differs from :meth:`__repr__` in that it does not have to be a valid Python expression: a more convenient or concise representation may be used instead. @@ -1344,7 +1344,7 @@ Basic customization ``False`` and ``True`` are returned for a successful comparison. However, these methods can return any value, so if the comparison operator is used in a Boolean context (e.g., in the condition of an ``if`` statement), Python will call - :func:`bool` on the value to determine if the result is true or false. + :class:`bool` on the value to determine if the result is true or false. There are no implied relationships among the comparison operators. The truth of ``x==y`` does not imply that ``x!=y`` is false. Accordingly, when @@ -1450,7 +1450,7 @@ Basic customization .. index:: builtin: unicode - Called to implement :func:`unicode` built-in; should return a Unicode object. + Called to implement :class:`unicode` built-in; should return a Unicode object. When this method is not defined, string conversion is attempted, and the result of string conversion is converted to Unicode using the system default encoding. @@ -1623,7 +1623,7 @@ descriptors have just the :meth:`__get__` method. Data descriptors with instance dictionary. In contrast, non-data descriptors can be overridden by instances. -Python methods (including :func:`staticmethod` and :func:`classmethod`) are +Python methods (including :func:`staticmethod` and :class:`classmethod`) are implemented as non-data descriptors. Accordingly, instances can redefine and override methods. This allows individual instances to acquire behaviors that differ from other instances of the same class. @@ -1717,12 +1717,12 @@ Notes on using *__slots__* Customizing class creation -------------------------- -By default, new-style classes are constructed using :func:`type`. A class +By default, new-style classes are constructed using :class:`type`. A class definition is read into a separate namespace and the value of class name is bound to the result of ``type(name, bases, dict)``. When the class definition is read, if *__metaclass__* is defined then the -callable assigned to it will be called instead of :func:`type`. This allows +callable assigned to it will be called instead of :class:`type`. This allows classes or functions to be written which monitor or alter the class creation process: @@ -1750,7 +1750,7 @@ behavior when the class is called, e.g. not always creating a new instance. This variable can be any callable accepting arguments for ``name``, ``bases``, and ``dict``. Upon class creation, the callable is used instead of the built-in - :func:`type`. + :class:`type`. .. versionadded:: 2.2 @@ -2190,8 +2190,8 @@ left undefined. builtin: long builtin: float - Called to implement the built-in functions :func:`complex`, :func:`int`, - :func:`long`, and :func:`float`. Should return a value of the appropriate type. + Called to implement the built-in functions :class:`complex`, :class:`int`, + :class:`long`, and :class:`float`. Should return a value of the appropriate type. .. method:: object.__oct__(self) diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 067a3d6..02d2a1e 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -374,7 +374,7 @@ reference, and the result cannot be passed to :func:`eval` to get an equal value The built-in function :func:`repr` performs exactly the same conversion in its argument as enclosing it in parentheses and reverse quotes does. The built-in -function :func:`str` performs a similar but more user-friendly conversion. +function :class:`str` performs a similar but more user-friendly conversion. .. _yieldexpr: diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst index ed0e655..b2f63a5 100644 --- a/Doc/tutorial/classes.rst +++ b/Doc/tutorial/classes.rst @@ -646,7 +646,7 @@ would have printed B, B, B --- the first matching except clause is triggered. When an error message is printed for an unhandled exception, the exception's class name is printed, then a colon and a space, and finally the instance -converted to a string using the built-in function :func:`str`. +converted to a string using the built-in function :class:`str`. .. _tut-iterators: diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index 226eadd..b1c2e80 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -502,7 +502,7 @@ Here is a small example using a dictionary:: >>> 'guido' in tel True -The :func:`dict` constructor builds dictionaries directly from lists of +The :class:`dict` constructor builds dictionaries directly from lists of key-value pairs stored as tuples. When the pairs form a pattern, list comprehensions can compactly specify the key-value list. :: @@ -512,7 +512,7 @@ comprehensions can compactly specify the key-value list. :: {2: 4, 4: 16, 6: 36} Later in the tutorial, we will learn about Generator Expressions which are even -better suited for the task of supplying key-values pairs to the :func:`dict` +better suited for the task of supplying key-values pairs to the :class:`dict` constructor. When the keys are simple strings, it is sometimes easier to specify pairs using diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index 3441f54..11a921e 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -32,13 +32,13 @@ yet another way to substitute values into strings. One question remains, of course: how do you convert values to strings? Luckily, Python has ways to convert any value to a string: pass it to the :func:`repr` -or :func:`str` functions. +or :class:`str` functions. -The :func:`str` function is meant to return representations of values which are +The :class:`str` function is meant to return representations of values which are fairly human-readable, while :func:`repr` is meant to generate representations which can be read by the interpreter (or will force a :exc:`SyntaxError` if there is not equivalent syntax). For objects which don't have a particular -representation for human consumption, :func:`str` will return the same value as +representation for human consumption, :class:`str` will return the same value as :func:`repr`. Many values, such as numbers or structures like lists and dictionaries, have the same representation using either function. Strings and floating point numbers, in particular, have two distinct representations. @@ -151,7 +151,7 @@ Positional and keyword arguments can be arbitrarily combined:: ... other='Georg') The story of Bill, Manfred, and Georg. -``'!s'`` (apply :func:`str`) and ``'!r'`` (apply :func:`repr`) can be used to +``'!s'`` (apply :class:`str`) and ``'!r'`` (apply :func:`repr`) can be used to convert the value before it is formatted. :: >>> import math @@ -382,7 +382,7 @@ The :mod:`pickle` Module Strings can easily be written to and read from a file. Numbers take a bit more effort, since the :meth:`read` method only returns strings, which will have to -be passed to a function like :func:`int`, which takes a string like ``'123'`` +be passed to a function like :class:`int`, which takes a string like ``'123'`` and returns its numeric value 123. However, when you want to save more complex data types like lists, dictionaries, or class instances, things get a lot more complicated. diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 6d8f890..8cd5e07 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -122,8 +122,8 @@ and imaginary part. To extract these parts from a complex number *z*, use >>> a.imag 0.5 -The conversion functions to floating point and integer (:func:`float`, -:func:`int` and :func:`long`) don't work for complex numbers --- there is no one +The conversion functions to floating point and integer (:class:`float`, +:class:`int` and :class:`long`) don't work for complex numbers --- there is no one correct way to convert a complex number to a real number. Use ``abs(z)`` to get its magnitude (as a float) or ``z.real`` to get its real part. :: @@ -465,14 +465,14 @@ of creating Unicode strings on the basis of a known encoding. .. index:: builtin: unicode -The built-in function :func:`unicode` provides access to all registered Unicode +The built-in function :class:`unicode` provides access to all registered Unicode codecs (COders and DECoders). Some of the more well known encodings which these codecs can convert are *Latin-1*, *ASCII*, *UTF-8*, and *UTF-16*. The latter two are variable-length encodings that store each Unicode character in one or more bytes. The default encoding is normally set to ASCII, which passes through characters in the range 0 to 127 and rejects any other characters with an error. When a Unicode string is printed, written to a file, or converted with -:func:`str`, conversion takes place using this default encoding. :: +:class:`str`, conversion takes place using this default encoding. :: >>> u"abc" u'abc' @@ -493,7 +493,7 @@ name of the encoding. Lowercase names for encodings are preferred. :: '\xc3\xa4\xc3\xb6\xc3\xbc' If you have data in a specific encoding and want to produce a corresponding -Unicode string from it, you can use the :func:`unicode` function with the +Unicode string from it, you can use the :class:`unicode` function with the encoding name as the second argument. :: >>> unicode('\xc3\xa4\xc3\xb6\xc3\xbc', 'utf-8') diff --git a/Doc/whatsnew/2.0.rst b/Doc/whatsnew/2.0.rst index 3bb12b6..d885113 100644 --- a/Doc/whatsnew/2.0.rst +++ b/Doc/whatsnew/2.0.rst @@ -532,7 +532,7 @@ by Thomas Wouters. A new format style is available when using the ``%`` operator; '%r' will insert the :func:`repr` of its argument. This was also added from symmetry considerations, this time for symmetry with the existing '%s' format style, -which inserts the :func:`str` of its argument. For example, ``'%r %s' % ('abc', +which inserts the :class:`str` of its argument. For example, ``'%r %s' % ('abc', 'abc')`` returns a string containing ``'abc' abc``. Previously there was no way to implement a class that overrode Python's built-in @@ -607,7 +607,7 @@ seq1, seq2)`` is that :func:`map` pads the sequences with ``None`` if the sequences aren't all of the same length, while :func:`zip` truncates the returned list to the length of the shortest argument sequence. -The :func:`int` and :func:`long` functions now accept an optional "base" +The :class:`int` and :class:`long` functions now accept an optional "base" parameter when the first argument is a string. ``int('123', 10)`` returns 123, while ``int('123', 16)`` returns 291. ``int(123, 16)`` raises a :exc:`TypeError` exception with the message "can't convert non-string with @@ -705,7 +705,7 @@ contexts where previously only integers were accepted, such as in the operator (``%d``, ``%i``, ``%x``, etc.). For example, ``"%d" % 2L**64`` will produce the string ``18446744073709551616``. -The subtlest long integer change of all is that the :func:`str` of a long +The subtlest long integer change of all is that the :class:`str` of a long integer no longer has a trailing 'L' character, though :func:`repr` still includes it. The 'L' annoyed many people who wanted to print long integers that looked just like regular integers, since they had to go out of their way to chop @@ -714,9 +714,9 @@ off the character. This is no longer a problem in 2.0, but code which does digit. Taking the :func:`repr` of a float now uses a different formatting precision -than :func:`str`. :func:`repr` uses ``%.17g`` format string for C's -:func:`sprintf`, while :func:`str` uses ``%.12g`` as before. The effect is that -:func:`repr` may occasionally show more decimal places than :func:`str`, for +than :class:`str`. :func:`repr` uses ``%.17g`` format string for C's +:func:`sprintf`, while :class:`str` uses ``%.12g`` as before. The effect is that +:func:`repr` may occasionally show more decimal places than :class:`str`, for certain numbers. For example, the number 8.1 can't be represented exactly in binary, so ``repr(8.1)`` is ``'8.0999999999999996'``, while str(8.1) is ``'8.1'``. diff --git a/Doc/whatsnew/2.1.rst b/Doc/whatsnew/2.1.rst index 7f40521..7a0d3c7 100644 --- a/Doc/whatsnew/2.1.rst +++ b/Doc/whatsnew/2.1.rst @@ -721,7 +721,7 @@ of the more notable changes are: A new module and method for file objects was also added, contributed by Jeff Epler. The new method, :meth:`xreadlines`, is similar to the existing - :func:`xrange` built-in. :func:`xreadlines` returns an opaque sequence object + :class:`xrange` built-in. :func:`xreadlines` returns an opaque sequence object that only supports being iterated over, reading a line on every iteration but not reading the entire file into memory as the existing :meth:`readlines` method does. You'd use it like this:: diff --git a/Doc/whatsnew/2.2.rst b/Doc/whatsnew/2.2.rst index 89e4d76..4adecd7 100644 --- a/Doc/whatsnew/2.2.rst +++ b/Doc/whatsnew/2.2.rst @@ -124,8 +124,8 @@ setting a module-level variable named :attr:`__metaclass__` --- see :pep:`253` for the details --- but it's easier to just subclass :keyword:`object`.) The type objects for the built-in types are available as built-ins, named using -a clever trick. Python has always had built-in functions named :func:`int`, -:func:`float`, and :func:`str`. In 2.2, they aren't functions any more, but +a clever trick. Python has always had built-in functions named :class:`int`, +:class:`float`, and :class:`str`. In 2.2, they aren't functions any more, but type objects that behave as factories when called. :: >>> int @@ -133,8 +133,8 @@ type objects that behave as factories when called. :: >>> int('123') 123 -To make the set of types complete, new type objects such as :func:`dict` and -:func:`file` have been added. Here's a more interesting example, adding a +To make the set of types complete, new type objects such as :class:`dict` and +:class:`file` have been added. Here's a more interesting example, adding a :meth:`lock` method to file objects:: class LockableFile(file): @@ -692,7 +692,7 @@ example:: 18446744073709551616L In most cases, integers and long integers will now be treated identically. You -can still distinguish them with the :func:`type` built-in function, but that's +can still distinguish them with the :class:`type` built-in function, but that's rarely needed. @@ -1212,7 +1212,7 @@ Some of the more notable changes are: * The :file:`Tools/scripts/ftpmirror.py` script now parses a :file:`.netrc` file, if you have one. (Contributed by Mike Romberg.) -* Some features of the object returned by the :func:`xrange` function are now +* Some features of the object returned by the :class:`xrange` function are now deprecated, and trigger warnings when they're accessed; they'll disappear in Python 2.3. :class:`xrange` objects tried to pretend they were full sequence types by supporting slicing, sequence multiplication, and the :keyword:`in` diff --git a/Doc/whatsnew/2.3.rst b/Doc/whatsnew/2.3.rst index 31a5fe2..c2ddae2 100644 --- a/Doc/whatsnew/2.3.rst +++ b/Doc/whatsnew/2.3.rst @@ -599,7 +599,7 @@ that arithmetic using a Boolean still works. :: To sum up :const:`True` and :const:`False` in a sentence: they're alternative ways to spell the integer values 1 and 0, with the single difference that -:func:`str` and :func:`repr` return the strings ``'True'`` and ``'False'`` +:class:`str` and :func:`repr` return the strings ``'True'`` and ``'False'`` instead of ``'1'`` and ``'0'``. @@ -972,7 +972,7 @@ Here are all of the changes that Python 2.3 makes to the core Python language. built-in :class:`bool` type, as described in section :ref:`section-bool` of this document. -* The :func:`int` type constructor will now return a long integer instead of +* The :class:`int` type constructor will now return a long integer instead of raising an :exc:`OverflowError` when a string or floating-point number is too large to fit into an integer. This can lead to the paradoxical result that ``isinstance(int(expression), int)`` is false, but that seems unlikely to cause @@ -1023,7 +1023,7 @@ Here are all of the changes that Python 2.3 makes to the core Python language. (Patches contributed by Raymond Hettinger.) - Also, the :func:`dict` constructor now accepts keyword arguments to simplify + Also, the :class:`dict` constructor now accepts keyword arguments to simplify creating small dictionaries:: >>> dict(red=1, blue=2, green=3, black=4) @@ -1198,7 +1198,7 @@ Optimizations increase, depending on your compiler's idiosyncrasies. See section :ref:`section-other` for a longer explanation. (Removed by Michael Hudson.) -* :func:`xrange` objects now have their own iterator, making ``for i in +* :class:`xrange` objects now have their own iterator, making ``for i in xrange(n)`` slightly faster than ``for i in range(n)``. (Patch by Raymond Hettinger.) @@ -1535,7 +1535,7 @@ complete list of changes, or look through the CVS logs for all the details. command line, or the module's :class:`Timer` class can be imported and used directly. Here's a short example that figures out whether it's faster to convert an 8-bit string to Unicode by appending an empty Unicode string to it or - by using the :func:`unicode` function:: + by using the :class:`unicode` function:: import timeit @@ -2014,7 +2014,7 @@ code: * For strings *X* and *Y*, ``X in Y`` now works if *X* is more than one character long. -* The :func:`int` type constructor will now return a long integer instead of +* The :class:`int` type constructor will now return a long integer instead of raising an :exc:`OverflowError` when a string or floating-point number is too large to fit into an integer. diff --git a/Doc/whatsnew/2.4.rst b/Doc/whatsnew/2.4.rst index fadde50..2735791 100644 --- a/Doc/whatsnew/2.4.rst +++ b/Doc/whatsnew/2.4.rst @@ -68,7 +68,7 @@ symmetric differences. :: >>> a set(['a', 'c', 'b', 'd', 'r', 'w', 'y', 'z']) -The :func:`frozenset` type is an immutable version of :func:`set`. Since it is +The :class:`frozenset` type is an immutable version of :class:`set`. Since it is immutable and hashable, it may be used as a dictionary key or as a member of another set. @@ -221,7 +221,7 @@ Python 2.2 extended Python's object model by adding static methods and class methods, but it didn't extend Python's syntax to provide any new way of defining static or class methods. Instead, you had to write a :keyword:`def` statement in the usual way, and pass the resulting method to a :func:`staticmethod` or -:func:`classmethod` function that would wrap up the function as a method of the +:class:`classmethod` function that would wrap up the function as a method of the new type. Your code would look like this:: class C: @@ -231,7 +231,7 @@ new type. Your code would look like this:: meth = classmethod(meth) # Rebind name to wrapped-up class method If the method was very long, it would be easy to miss or forget the -:func:`classmethod` invocation after the function body. +:class:`classmethod` invocation after the function body. The intention was always to add some syntax to make such definitions more readable, but at the time of 2.2's release a good syntax was not obvious. Today @@ -239,7 +239,7 @@ a good syntax *still* isn't obvious but users are asking for easier access to the feature; a new syntactic feature has been added to meet this need. The new feature is called "function decorators". The name comes from the idea -that :func:`classmethod`, :func:`staticmethod`, and friends are storing +that :class:`classmethod`, :func:`staticmethod`, and friends are storing additional information on a function object; they're *decorating* functions with more details. @@ -360,7 +360,7 @@ Compared to extended slicing, such as ``range(1,4)[::-1]``, :func:`reversed` is easier to read, runs faster, and uses substantially less memory. Note that :func:`reversed` only accepts sequences, not arbitrary iterators. If -you want to reverse an iterator, first convert it to a list with :func:`list`. +you want to reverse an iterator, first convert it to a list with :class:`list`. :: >>> input = open('/etc/passwd', 'r') @@ -774,7 +774,7 @@ Here are all of the changes that Python 2.4 makes to the core Python language. * Decorators for functions and methods were added (:pep:`318`). -* Built-in :func:`set` and :func:`frozenset` types were added (:pep:`218`). +* Built-in :class:`set` and :class:`frozenset` types were added (:pep:`218`). Other new built-ins include the :func:`reversed(seq)` function (:pep:`322`). * Generator expressions were added (:pep:`289`). @@ -942,7 +942,7 @@ Optimizations also optimized and no longer converts its argument into a temporary list before extending the base list. (Contributed by Raymond Hettinger.) -* :func:`list`, :func:`tuple`, :func:`map`, :func:`filter`, and :func:`zip` now +* :class:`list`, :class:`tuple`, :func:`map`, :func:`filter`, and :func:`zip` now run several times faster with non-sequence arguments that supply a :meth:`__len__` method. (Contributed by Raymond Hettinger.) @@ -1153,7 +1153,7 @@ complete list of changes, or look through the CVS logs for all the details. iterator; in the worst case, it may need to keep all of them. This should therefore be used carefully if the leading iterator can run far ahead of the trailing iterator in a long stream of inputs. If the separation is large, then - you might as well use :func:`list` instead. When the iterators track closely + you might as well use :class:`list` instead. When the iterators track closely with one another, :func:`tee` is ideal. Possible applications include bookmarking, windowing, or lookahead iterators. (Contributed by Raymond Hettinger.) diff --git a/Doc/whatsnew/2.5.rst b/Doc/whatsnew/2.5.rst index c7f7d58..90caad7 100644 --- a/Doc/whatsnew/2.5.rst +++ b/Doc/whatsnew/2.5.rst @@ -1244,7 +1244,7 @@ complete list of changes, or look through the SVN logs for all the details. The first argument to :class:`defaultdict`'s constructor is a factory function that gets called whenever a key is requested but not found. This factory function receives no arguments, so you can use built-in type constructors such - as :func:`list` or :func:`int`. For example, you can make an index of words + as :class:`list` or :class:`int`. For example, you can make an index of words based on their initial letter like this:: words = """Nel mezzo del cammin di nostra vita diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst index ccc97b8..a34d157 100644 --- a/Doc/whatsnew/2.6.rst +++ b/Doc/whatsnew/2.6.rst @@ -953,7 +953,7 @@ The 2.6 :class:`str` differs from 3.0's :class:`bytes` type in various ways; most notably, the constructor is completely different. In 3.0, ``bytes([65, 66, 67])`` is 3 elements long, containing the bytes representing ``ABC``; in 2.6, ``bytes([65, 66, 67])`` returns the -12-byte string representing the :func:`str` of the list. +12-byte string representing the :class:`str` of the list. The primary use of :class:`bytes` in 2.6 will be to write tests of object type such as ``isinstance(x, bytes)``. This will help the 2to3 @@ -1329,7 +1329,7 @@ builtin returns the binary representation for a number:: >>> bin(173) '0b10101101' -The :func:`int` and :func:`long` builtins will now accept the "0o" +The :class:`int` and :class:`long` builtins will now accept the "0o" and "0b" prefixes when base-8 or base-2 are requested, or when the *base* argument is zero (signalling that the base used should be determined from the string):: @@ -1590,7 +1590,7 @@ Some smaller changes made to the core Python language are: (Contributed by Raymond Hettinger.) -* Many floating-point features were added. The :func:`float` function +* Many floating-point features were added. The :class:`float` function will now turn the string ``nan`` into an IEEE 754 Not A Number value, and ``+inf`` and ``-inf`` into positive or negative infinity. This works on any platform with @@ -1619,7 +1619,7 @@ Some smaller changes made to the core Python language are: * A numerical nicety: when creating a complex number from two floats on systems that support signed zeros (-0 and +0), the - :func:`complex` constructor will now preserve the sign + :class:`complex` constructor will now preserve the sign of the zero. (Fixed by Mark T. Dickinson; :issue:`1507`.) * Classes that inherit a :meth:`__hash__` method from a parent class @@ -1652,7 +1652,7 @@ Some smaller changes made to the core Python language are: as well as positional parameters. (Contributed by Thomas Wouters; :issue:`1444529`.) -* The :func:`complex` constructor now accepts strings containing +* The :class:`complex` constructor now accepts strings containing parenthesized complex numbers, meaning that ``complex(repr(cplx))`` will now round-trip values. For example, ``complex('(3+4j)')`` now returns the value (3+4j). (:issue:`1491866`) diff --git a/Doc/whatsnew/2.7.rst b/Doc/whatsnew/2.7.rst index 6cd3aba..b6cf229 100644 --- a/Doc/whatsnew/2.7.rst +++ b/Doc/whatsnew/2.7.rst @@ -669,7 +669,7 @@ Some smaller changes made to the core Python language are: * Conversions between floating-point numbers and strings are now correctly rounded on most platforms. These conversions occur - in many different places: :func:`str` on + in many different places: :class:`str` on floats and complex numbers; the :class:`float` and :class:`complex` constructors; numeric formatting; serializing and @@ -766,7 +766,7 @@ Some smaller changes made to the core Python language are: precision, presumably you're expecting the formatting to be applied in some object-specific way. (Fixed by Eric Smith; :issue:`7994`.) -* The :func:`int` and :func:`long` types gained a ``bit_length`` +* The :class:`int` and :class:`long` types gained a ``bit_length`` method that returns the number of bits necessary to represent its argument in binary:: @@ -2359,7 +2359,7 @@ that may require changes to your code: * The string :meth:`format` method changed the default precision used for floating-point and complex numbers from 6 decimal - places to 12, which matches the precision used by :func:`str`. + places to 12, which matches the precision used by :class:`str`. (Changed by Eric Smith; :issue:`5920`.) * Because of an optimization for the :keyword:`with` statement, the special