("hreftype", HREFTYPE)]
class TYPEDESC(Structure):
+ _anonymous_ = ("u",)
_fields_ = [("u", _U),
("vt", VARTYPE)]
- _anonymous_ = ("u",)
The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field
specifies which one of the union fields is valid. Since the ``u`` field
microseconds should not be used, as :class:`date` objects have no such
values. If they're used anyway, ``0`` is substituted for them.
-:class:`time` and :class:`datetime` objects support a ``%f`` format code
-which expands to the number of microseconds in the object, zero-padded on
-the left to six places.
-
For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty
strings.
(1)
When used with the :func:`strptime` function, the ``%f`` directive
accepts from one to six digits and zero pads on the right. ``%f`` is
- an extension to the set of format characters in the C standard.
+ an extension to the set of format characters in the C standard (but
+ implemented separately in datetime objects, and therefore always
+ available).
(2)
When used with the :func:`strptime` function, the ``%p`` directive only affects
.. function:: uniform(a, b)
- Return a random floating point number *N* such that ``a <= N < b`` for
- ``a <= b`` and ``b <= N < a`` for ``b < a``.
+ Return a random floating point number *N* such that ``a <= N <= b`` for
+ ``a <= b`` and ``b <= N <= a`` for ``b < a``.
.. function:: triangular(low, high, mode)
- Return a random floating point number *N* such that ``low <= N < high`` and
+ Return a random floating point number *N* such that ``low <= N <= high`` and
with the specified *mode* between those bounds. The *low* and *high* bounds
default to zero and one. The *mode* argument defaults to the midpoint
between the bounds, giving a symmetric distribution.
.. function:: betavariate(alpha, beta)
- Beta distribution. Conditions on the parameters are ``alpha > 0`` and ``beta >
- 0``. Returned values range between 0 and 1.
+ Beta distribution. Conditions on the parameters are ``alpha > 0`` and
+ ``beta > 0``. Returned values range between 0 and 1.
.. function:: expovariate(lambd)
.. function:: gammavariate(alpha, beta)
- Gamma distribution. (*Not* the gamma function!) Conditions on the parameters
- are ``alpha > 0`` and ``beta > 0``.
+ Gamma distribution. (*Not* the gamma function!) Conditions on the
+ parameters are ``alpha > 0`` and ``beta > 0``.
.. function:: gauss(mu, sigma)
- Gaussian distribution. *mu* is the mean, and *sigma* is the standard deviation.
- This is slightly faster than the :func:`normalvariate` function defined below.
+ Gaussian distribution. *mu* is the mean, and *sigma* is the standard
+ deviation. This is slightly faster than the :func:`normalvariate` function
+ defined below.
.. function:: lognormvariate(mu, sigma)
All :class:`numbers.Real` types (:class:`int` and
:class:`float`) also include the following operations:
-+--------------------+--------------------------------+--------+
-| Operation | Result | Notes |
-+====================+================================+========+
-| ``trunc(x)`` | *x* truncated to Integral | |
-+--------------------+--------------------------------+--------+
-| ``round(x[, n])`` | *x* rounded to n digits, | |
-| | rounding half to even. If n is | |
-| | omitted, it defaults to 0. | |
-+--------------------+--------------------------------+--------+
-| ``math.floor(x)`` | the greatest Integral <= *x* | |
-+--------------------+--------------------------------+--------+
-| ``math.ceil(x)`` | the least Integral >= *x* | |
-+--------------------+--------------------------------+--------+
++--------------------+------------------------------------+--------+
+| Operation | Result | Notes |
++====================+====================================+========+
+| ``math.trunc(x)`` | *x* truncated to Integral | |
++--------------------+------------------------------------+--------+
+| ``round(x[, n])`` | *x* rounded to n digits, | |
+| | rounding half to even. If n is | |
+| | omitted, it defaults to 0. | |
++--------------------+------------------------------------+--------+
+| ``math.floor(x)`` | the greatest integral float <= *x* | |
++--------------------+------------------------------------+--------+
+| ``math.ceil(x)`` | the least integral float >= *x* | |
++--------------------+------------------------------------+--------+
For additional numeric operations see the :mod:`math` and :mod:`cmath`
modules.
==================================================================================================================
There are six sequence types: strings, byte sequences (:class:`bytes` objects),
-byte arrays (:class:`bytearray` objects), lists, tuples, and range objects.
+byte arrays (:class:`bytearray` objects), lists, tuples, and range objects. For
+other containers see the built in :class:`dict` and :class:`set` classes, and
+the :mod:`collections` module.
-For other containers see the built-in :class:`dict`, :class:`list`,
-:class:`set`, and :class:`tuple` classes, and the :mod:`collections` module.
.. index::
object: sequence
.. method:: union(other, ...)
set | other | ...
- Return a new set with elements from both sets.
+ Return a new set with elements from the set and all others.
.. method:: intersection(other, ...)
set & other & ...
- Return a new set with elements common to both sets.
+ Return a new set with elements common to the set and all others.
.. method:: difference(other, ...)
set - other - ...
slicing notations can be used as the target of assignment and :keyword:`del`
(delete) statements.
- There is currently a single intrinsic mutable sequence type:
+ There are currently two intrinsic mutable sequence types:
Lists
.. index:: object: list
object.__ixor__(self, other)
object.__ior__(self, other)
- These methods are called to implement the augmented arithmetic operations
+ These methods are called to implement the augmented arithmetic assignments
(``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``, ``>>=``,
``&=``, ``^=``, ``|=``). These methods should attempt to do the operation
in-place (modifying *self*) and return the result (which could be, but does
not have to be, *self*). If a specific method is not defined, the augmented
- operation falls back to the normal methods. For instance, to evaluate the
- expression ``x += y``, where *x* is an instance of a class that has an
+ assignment falls back to the normal methods. For instance, to execute the
+ statement ``x += y``, where *x* is an instance of a class that has an
:meth:`__iadd__` method, ``x.__iadd__(y)`` is called. If *x* is an instance
of a class that does not define a :meth:`__iadd__` method, ``x.__add__(y)``
and ``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``.
operation and an assignment statement:
.. productionlist::
- augmented_assignment_stmt: `target` `augop` (`expression_list` | `yield_expression`)
+ augmented_assignment_stmt: `augtarget` `augop` (`expression_list` | `yield_expression`)
+ augtarget: `identifier` | `attributeref` | `subscription` | `slicing`
augop: "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="
: | ">>=" | "<<=" | "&=" | "^=" | "|="
#
# 01/2009, Georg Brandl
+# TODO: - wrong versions in versionadded/changed
+# - wrong markup after versionchanged directive
+
from __future__ import with_statement
import os
specs = []
if defaults:
firstdefault = len(args) - len(defaults)
- for i in range(len(args)):
- spec = strseq(args[i], formatargandannotation, join)
+ for i, arg in enumerate(args):
+ spec = strseq(arg, formatargandannotation, join)
if defaults and i >= firstdefault:
spec = spec + formatvalue(defaults[i - firstdefault])
specs.append(spec)
encs = ("ascii", "latin-1", "iso-8859-1", "iso-8859-15")
for res in results:
- codecs.register_error("test.badhandler", lambda: res)
+ codecs.register_error("test.badhandler", lambda x: res)
for enc in encs:
self.assertRaises(
TypeError,
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */
-extern void Py_FatalError(char *msg);
+extern void Py_FatalError(const char *msg);
/*@-exportheader@*/
void ffi_prep_args(char *stack, extended_cif *ecif)
PyExc_MemoryErrorInst = BaseException_new(&_PyExc_MemoryError, NULL, NULL);
if (!PyExc_MemoryErrorInst)
- Py_FatalError("Cannot pre-allocate MemoryError instance\n");
+ Py_FatalError("Cannot pre-allocate MemoryError instance");
PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL);
if (!PyExc_RecursionErrorInst)
default: {
char buf[128];
- sprintf(buf, "Non-statement found: %d %d\n",
+ sprintf(buf, "Non-statement found: %d %d",
TYPE(n), NCH(n));
Py_FatalError(buf);
}
char buf[350];
PyOS_snprintf(buf, sizeof(buf),
"unknown scope for %.100s in %.100s(%s) in %s\n"
- "symbols: %s\nlocals: %s\nglobals: %s\n",
+ "symbols: %s\nlocals: %s\nglobals: %s",
PyBytes_AS_STRING(name),
PyBytes_AS_STRING(c->u->u_name),
PyObject_REPR(c->u->u_ste->ste_id),