~ubuntu-branches/ubuntu/precise/python3.2/precise-proposed

« back to all changes in this revision

Viewing changes to Doc/library/functions.rst

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-03-09 18:40:39 UTC
  • mfrom: (30.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120309184039-j3yk2emxr1plyo21
Tags: 3.2.3~rc1-1
* Python 3.2.3 release candidate 1.
* Update to 20120309 from the 3.2 branch.
* Fix libpython.a symlink. Closes: #660146.
* Build-depend on xauth.
* Run the gdb tests for the debug build only.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
===================  =================  ==================  ================  ====================
11
11
..                   ..                 Built-in Functions  ..                ..
12
12
===================  =================  ==================  ================  ====================
13
 
:func:`abs`          :func:`dict`       :func:`help`        :func:`min`       :func:`setattr`
 
13
:func:`abs`          |func-dict|_       :func:`help`        :func:`min`       :func:`setattr`
14
14
:func:`all`          :func:`dir`        :func:`hex`         :func:`next`      :func:`slice`
15
15
:func:`any`          :func:`divmod`     :func:`id`          :func:`object`    :func:`sorted`
16
16
:func:`ascii`        :func:`enumerate`  :func:`input`       :func:`oct`       :func:`staticmethod`
19
19
:func:`bytearray`    :func:`filter`     :func:`issubclass`  :func:`pow`       :func:`super`
20
20
:func:`bytes`        :func:`float`      :func:`iter`        :func:`print`     :func:`tuple`
21
21
:func:`callable`     :func:`format`     :func:`len`         :func:`property`  :func:`type`
22
 
:func:`chr`          :func:`frozenset`  :func:`list`        :func:`range`     :func:`vars`
 
22
:func:`chr`          |func-frozenset|_  :func:`list`        :func:`range`     :func:`vars`
23
23
:func:`classmethod`  :func:`getattr`    :func:`locals`      :func:`repr`      :func:`zip`
24
24
:func:`compile`      :func:`globals`    :func:`map`         :func:`reversed`  :func:`__import__`
25
25
:func:`complex`      :func:`hasattr`    :func:`max`         :func:`round`
26
 
:func:`delattr`      :func:`hash`       :func:`memoryview`  :func:`set`
 
26
:func:`delattr`      :func:`hash`       |func-memoryview|_  |func-set|_
27
27
===================  =================  ==================  ================  ====================
28
28
 
 
29
.. using :func:`dict` would create a link to another page, so local targets are
 
30
   used, with replacement texts to make the output in the table consistent
 
31
 
 
32
.. |func-dict| replace:: ``dict()``
 
33
.. |func-frozenset| replace:: ``frozenset()``
 
34
.. |func-memoryview| replace:: ``memoryview()``
 
35
.. |func-set| replace:: ``set()``
 
36
 
 
37
 
29
38
.. function:: abs(x)
30
39
 
31
40
   Return the absolute value of a number.  The argument may be an
74
83
 
75
84
.. function:: bool([x])
76
85
 
77
 
   Convert a value to a Boolean, using the standard truth testing procedure.  If
78
 
   *x* is false or omitted, this returns :const:`False`; otherwise it returns
79
 
   :const:`True`. :class:`bool` is also a class, which is a subclass of
80
 
   :class:`int`. Class :class:`bool` cannot be subclassed further.  Its only
81
 
   instances are :const:`False` and :const:`True`.
 
86
   Convert a value to a Boolean, using the standard :ref:`truth testing
 
87
   procedure <truth>`.  If *x* is false or omitted, this returns ``False``;
 
88
   otherwise it returns ``True``. :class:`bool` is also a class, which is a
 
89
   subclass of :class:`int` (see :ref:`typesnumeric`).  Class :class:`bool`
 
90
   cannot be subclassed further.  Its only instances are ``False`` and
 
91
   ``True`` (see :ref:`bltin-boolean-values`).
82
92
 
83
93
   .. index:: pair: Boolean; type
84
94
 
248
258
   example, ``delattr(x, 'foobar')`` is equivalent to ``del x.foobar``.
249
259
 
250
260
 
 
261
.. _func-dict:
251
262
.. function:: dict([arg])
252
263
   :noindex:
253
264
 
491
502
 
492
503
   The float type is described in :ref:`typesnumeric`.
493
504
 
 
505
 
494
506
.. function:: format(value[, format_spec])
495
507
 
496
508
   .. index::
511
523
   :exc:`TypeError` exception is raised if the method is not found or if either
512
524
   the *format_spec* or the return value are not strings.
513
525
 
 
526
 
 
527
.. _func-frozenset:
514
528
.. function:: frozenset([iterable])
515
529
   :noindex:
516
530
 
624
638
.. function:: isinstance(object, classinfo)
625
639
 
626
640
   Return true if the *object* argument is an instance of the *classinfo*
627
 
   argument, or of a (direct or indirect) subclass thereof.  If *object* is not
 
641
   argument, or of a (direct, indirect or :term:`virtual <abstract base
 
642
   class>`) subclass thereof.  If *object* is not
628
643
   an object of the given type, the function always returns false.  If
629
644
   *classinfo* is not a class (type object), it may be a tuple of type objects,
630
645
   or may recursively contain other such tuples (other sequence types are not
634
649
 
635
650
.. function:: issubclass(class, classinfo)
636
651
 
637
 
   Return true if *class* is a subclass (direct or indirect) of *classinfo*.  A
 
652
   Return true if *class* is a subclass (direct, indirect or :term:`virtual
 
653
   <abstract base class>`) of *classinfo*.  A
638
654
   class is considered a subclass of itself. *classinfo* may be a tuple of class
639
655
   objects, in which case every entry in *classinfo* will be checked. In any other
640
656
   case, a :exc:`TypeError` exception is raised.
715
731
   such as ``sorted(iterable, key=keyfunc, reverse=True)[0]`` and
716
732
   ``heapq.nlargest(1, iterable, key=keyfunc)``.
717
733
 
 
734
 
 
735
.. _func-memoryview:
718
736
.. function:: memoryview(obj)
719
737
   :noindex:
720
738
 
810
828
   .. note::
811
829
 
812
830
      Python doesn't depend on the underlying operating system's notion of text
813
 
      files; all the the processing is done by Python itself, and is therefore
 
831
      files; all the processing is done by Python itself, and is therefore
814
832
      platform-independent.
815
833
 
816
834
   *buffering* is an optional integer used to set the buffering policy.  Pass 0
898
916
.. XXX works for bytes too, but should it?
899
917
.. function:: ord(c)
900
918
 
901
 
   Given a string representing one Uncicode character, return an integer
 
919
   Given a string representing one Unicode character, return an integer
902
920
   representing the Unicode code
903
921
   point of that character.  For example, ``ord('a')`` returns the integer ``97``
904
922
   and ``ord('\u2020')`` returns ``8224``.  This is the inverse of :func:`chr`.
936
954
   *end*.
937
955
 
938
956
   The *file* argument must be an object with a ``write(string)`` method; if it
939
 
   is not present or ``None``, :data:`sys.stdout` will be used.
 
957
   is not present or ``None``, :data:`sys.stdout` will be used. Output buffering
 
958
   is determined by *file*. Use ``file.flush()`` to ensure, for instance,
 
959
   immediate appearance on a screen.
940
960
 
941
961
 
942
962
.. function:: property(fget=None, fset=None, fdel=None, doc=None)
1038
1058
 
1039
1059
   Range objects implement the :class:`collections.Sequence` ABC, and provide
1040
1060
   features such as containment tests, element index lookup, slicing and
1041
 
   support for negative indices:
 
1061
   support for negative indices (see :ref:`typesseq`):
1042
1062
 
1043
1063
      >>> r = range(0, 20, 2)
1044
1064
      >>> r
1106
1126
      can't be represented exactly as a float.  See :ref:`tut-fp-issues` for
1107
1127
      more information.
1108
1128
 
 
1129
 
 
1130
.. _func-set:
1109
1131
.. function:: set([iterable])
1110
1132
   :noindex:
1111
1133
 
1347
1369
        def zip(*iterables):
1348
1370
            # zip('ABCD', 'xy') --> Ax By
1349
1371
            sentinel = object()
1350
 
            iterables = [iter(it) for it in iterables]
1351
 
            while iterables:
 
1372
            iterators = [iter(it) for it in iterables]
 
1373
            while iterators:
1352
1374
                result = []
1353
 
                for it in iterables:
 
1375
                for it in iterators:
1354
1376
                    elem = next(it, sentinel)
1355
1377
                    if elem is sentinel:
1356
1378
                        return