File indexing completed on 2024-04-28 15:53:57
0001 #!/usr/bin/env python2.7 0002 # -*- coding: utf-8 -*- 0003 """ 0004 Built-in Functions 0005 ================== 0006 0007 The Python interpreter has a number of functions built into it that are always 0008 available. They are listed here in alphabetical order. 0009 0010 =================== ================= ================== ================= ==================== 0011 .. .. Built-in Functions .. .. 0012 =================== ================= ================== ================= ==================== 0013 :func:`abs` :func:`divmod` :func:`input` :func:`open` :func:`staticmethod` 0014 :func:`all` :func:`enumerate` :func:`int` :func:`ord` :func:`str` 0015 :func:`any` :func:`eval` :func:`isinstance` :func:`pow` :func:`sum` 0016 :func:`basestring` :func:`execfile` :func:`issubclass` :func:`print` :func:`super` 0017 :func:`bin` :func:`file` :func:`iter` :func:`property` :func:`tuple` 0018 :func:`bool` :func:`filter` :func:`len` :func:`range` :func:`type` 0019 :func:`bytearray` :func:`float` :func:`list` :func:`raw_input` :func:`unichr` 0020 :func:`callable` :func:`format` :func:`locals` :func:`reduce` :func:`unicode` 0021 :func:`chr` :func:`frozenset` :func:`long` :func:`reload` :func:`vars` 0022 :func:`classmethod` :func:`getattr` :func:`map` :func:`repr` :func:`xrange` 0023 :func:`cmp` :func:`globals` :func:`max` :func:`reversed` :func:`zip` 0024 :func:`compile` :func:`hasattr` :func:`memoryview` :func:`round` :func:`__import__` 0025 :func:`complex` :func:`hash` :func:`min` :func:`set` :func:`apply` 0026 :func:`delattr` :func:`help` :func:`next` :func:`setattr` :func:`buffer` 0027 :func:`dict` :func:`hex` :func:`object` :func:`slice` :func:`coerce` 0028 :func:`dir` :func:`id` :func:`oct` :func:`sorted` :func:`intern` 0029 =================== ================= ================== ================= ==================== 0030 0031 """ 0032 def abs(x): 0033 """ 0034 Return the absolute value of a number. The argument may be a plain or long 0035 integer or a floating point number. If the argument is a complex number, its 0036 magnitude is returned. 0037 0038 0039 """ 0040 pass 0041 0042 def all(iterable): 0043 """ 0044 Return True if all elements of the *iterable* are true (or if the iterable 0045 is empty). Equivalent to:: 0046 0047 def all(iterable): 0048 for element in iterable: 0049 if not element: 0050 return False 0051 return True 0052 0053 """ 0054 pass 0055 0056 def any(iterable): 0057 """ 0058 Return True if any element of the *iterable* is true. If the iterable 0059 is empty, return False. Equivalent to:: 0060 0061 def any(iterable): 0062 for element in iterable: 0063 if element: 0064 return True 0065 return False 0066 0067 """ 0068 pass 0069 0070 def basestring(): 0071 """ 0072 This abstract type is the superclass for :class:`str` and :class:`unicode`. It 0073 cannot be called or instantiated, but it can be used to test whether an object 0074 is an instance of :class:`str` or :class:`unicode`. ``isinstance(obj, 0075 basestring)`` is equivalent to ``isinstance(obj, (str, unicode))``. 0076 0077 """ 0078 pass 0079 0080 def bin(x): 0081 """ 0082 Convert an integer number to a binary string. The result is a valid Python 0083 expression. If *x* is not a Python :class:`int` object, it has to define an 0084 :meth:`__index__` method that returns an integer. 0085 0086 """ 0087 pass 0088 0089 def bool(x): 0090 """ 0091 Convert a value to a Boolean, using the standard truth testing procedure. If 0092 *x* is false or omitted, this returns :const:`False`; otherwise it returns 0093 :const:`True`. :class:`bool` is also a class, which is a subclass of 0094 :class:`int`. Class :class:`bool` cannot be subclassed further. Its only 0095 instances are :const:`False` and :const:`True`. 0096 0097 """ 0098 pass 0099 0100 def bytearray(source,encoding,errors): 0101 """ 0102 Return a new array of bytes. The :class:`bytearray` type is a mutable 0103 sequence of integers in the range 0 <= x < 256. It has most of the usual 0104 methods of mutable sequences, described in :ref:`typesseq-mutable`, as well 0105 as most methods that the :class:`str` type has, see :ref:`string-methods`. 0106 0107 The optional *source* parameter can be used to initialize the array in a few 0108 different ways: 0109 0110 * If it is a *string*, you must also give the *encoding* (and optionally, 0111 *errors*) parameters; :func:`bytearray` then converts the string to 0112 bytes using :meth:`str.encode`. 0113 0114 * If it is an *integer*, the array will have that size and will be 0115 initialized with null bytes. 0116 0117 * If it is an object conforming to the *buffer* interface, a read-only buffer 0118 of the object will be used to initialize the bytes array. 0119 0120 * If it is an *iterable*, it must be an iterable of integers in the range 0121 ``0 <= x < 256``, which are used as the initial contents of the array. 0122 0123 Without an argument, an array of size 0 is created. 0124 0125 0126 """ 0127 pass 0128 0129 def callable(object): 0130 """ 0131 Return :const:`True` if the *object* argument appears callable, 0132 :const:`False` if not. If this 0133 returns true, it is still possible that a call fails, but if it is false, 0134 calling *object* will never succeed. Note that classes are callable (calling a 0135 class returns a new instance); class instances are callable if they have a 0136 :meth:`__call__` method. 0137 0138 0139 """ 0140 pass 0141 0142 def chr(i): 0143 """ 0144 Return a string of one character whose ASCII code is the integer *i*. For 0145 example, ``chr(97)`` returns the string ``'a'``. This is the inverse of 0146 :func:`ord`. The argument must be in the range [0..255], inclusive; 0147 :exc:`ValueError` will be raised if *i* is outside that range. See 0148 also :func:`unichr`. 0149 0150 0151 """ 0152 pass 0153 0154 def _classmethod(function): 0155 """ 0156 Return a class method for *function*. 0157 0158 A class method receives the class as implicit first argument, just like an 0159 instance method receives the instance. To declare a class method, use this 0160 idiom:: 0161 0162 class C: 0163 @classmethod 0164 def f(cls, arg1, arg2, more): more 0165 0166 The ``@classmethod`` form is a function :term:`decorator` -- see the description 0167 of function definitions in :ref:`function` for details. 0168 0169 It can be called either on the class (such as ``C.f()``) or on an instance (such 0170 as ``C().f()``). The instance is ignored except for its class. If a class 0171 method is called for a derived class, the derived class object is passed as the 0172 implied first argument. 0173 0174 Class methods are different than C++ or Java static methods. If you want those, 0175 see :func:`staticmethod` in this section. 0176 0177 For more information on class methods, consult the documentation on the standard 0178 type hierarchy in :ref:`types`. 0179 0180 """ 0181 pass 0182 0183 def cmp(x,y): 0184 """ 0185 Compare the two objects *x* and *y* and return an integer according to the 0186 outcome. The return value is negative if ``x < y``, zero if ``x == y`` and 0187 strictly positive if ``x > y``. 0188 0189 0190 """ 0191 pass 0192 0193 def compile(source,filename,mode,flags,dont_inherit): 0194 """ 0195 Compile the *source* into a code or AST object. Code objects can be executed 0196 by an :keyword:`exec` statement or evaluated by a call to :func:`eval`. 0197 *source* can either be a string or an AST object. Refer to the :mod:`ast` 0198 module documentation for information on how to work with AST objects. 0199 0200 The *filename* argument should give the file from which the code was read; 0201 pass some recognizable value if it wasn't read from a file (``'<string>'`` is 0202 commonly used). 0203 0204 The *mode* argument specifies what kind of code must be compiled; it can be 0205 ``'exec'`` if *source* consists of a sequence of statements, ``'eval'`` if it 0206 consists of a single expression, or ``'single'`` if it consists of a single 0207 interactive statement (in the latter case, expression statements that 0208 evaluate to something other than ``None`` will be printed). 0209 0210 The optional arguments *flags* and *dont_inherit* control which future 0211 statements (see :pep:`236`) affect the compilation of *source*. If neither 0212 is present (or both are zero) the code is compiled with those future 0213 statements that are in effect in the code that is calling compile. If the 0214 *flags* argument is given and *dont_inherit* is not (or is zero) then the 0215 future statements specified by the *flags* argument are used in addition to 0216 those that would be used anyway. If *dont_inherit* is a non-zero integer then 0217 the *flags* argument is it -- the future statements in effect around the call 0218 to compile are ignored. 0219 0220 Future statements are specified by bits which can be bitwise ORed together to 0221 specify multiple statements. The bitfield required to specify a given feature 0222 can be found as the :attr:`compiler_flag` attribute on the :class:`_Feature` 0223 instance in the :mod:`__future__` module. 0224 0225 This function raises :exc:`SyntaxError` if the compiled source is invalid, 0226 and :exc:`TypeError` if the source contains null bytes. 0227 0228 """ 0229 pass 0230 0231 def complex(real,imag): 0232 """ 0233 Create a complex number with the value *real* + *imag*\*j or convert a string or 0234 number to a complex number. If the first parameter is a string, it will be 0235 interpreted as a complex number and the function must be called without a second 0236 parameter. The second parameter can never be a string. Each argument may be any 0237 numeric type (including complex). If *imag* is omitted, it defaults to zero and 0238 the function serves as a numeric conversion function like :func:`int`, 0239 :func:`long` and :func:`float`. If both arguments are omitted, returns ``0j``. 0240 0241 The complex type is described in :ref:`typesnumeric`. 0242 0243 0244 """ 0245 pass 0246 0247 def delattr(object,name): 0248 """ 0249 This is a relative of :func:`setattr`. The arguments are an object and a 0250 string. The string must be the name of one of the object's attributes. The 0251 function deletes the named attribute, provided the object allows it. For 0252 example, ``delattr(x, 'foobar')`` is equivalent to ``del x.foobar``. 0253 0254 0255 """ 0256 pass 0257 0258 def dict(arg): 0259 """:noindex: 0260 0261 Create a new data dictionary, optionally with items taken from *arg*. 0262 The dictionary type is described in :ref:`typesmapping`. 0263 0264 For other containers see the built in :class:`list`, :class:`set`, and 0265 :class:`tuple` classes, and the :mod:`collections` module. 0266 0267 0268 """ 0269 pass 0270 0271 def dir(object): 0272 """ 0273 Without arguments, return the list of names in the current local scope. With an 0274 argument, attempt to return a list of valid attributes for that object. 0275 0276 If the object has a method named :meth:`__dir__`, this method will be called and 0277 must return the list of attributes. This allows objects that implement a custom 0278 :func:`__getattr__` or :func:`__getattribute__` function to customize the way 0279 :func:`dir` reports their attributes. 0280 0281 If the object does not provide :meth:`__dir__`, the function tries its best to 0282 gather information from the object's :attr:`__dict__` attribute, if defined, and 0283 from its type object. The resulting list is not necessarily complete, and may 0284 be inaccurate when the object has a custom :func:`__getattr__`. 0285 0286 The default :func:`dir` mechanism behaves differently with different types of 0287 objects, as it attempts to produce the most relevant, rather than complete, 0288 information: 0289 0290 * If the object is a module object, the list contains the names of the module's 0291 attributes. 0292 0293 * If the object is a type or class object, the list contains the names of its 0294 attributes, and recursively of the attributes of its bases. 0295 0296 * Otherwise, the list contains the object's attributes' names, the names of its 0297 class's attributes, and recursively of the attributes of its class's base 0298 classes. 0299 0300 The resulting list is sorted alphabetically. For example: 0301 0302 >>> import struct 0303 >>> dir() # doctest: +SKIP 0304 ['__builtins__', '__doc__', '__name__', 'struct'] 0305 >>> dir(struct) # doctest: +NORMALIZE_WHITESPACE 0306 ['Struct', '__builtins__', '__doc__', '__file__', '__name__', 0307 '__package__', '_clearcache', 'calcsize', 'error', 'pack', 'pack_into', 0308 'unpack', 'unpack_from'] 0309 >>> class Foo(object): 0310 more def __dir__(self): 0311 more return ["kan", "ga", "roo"] 0312 more 0313 >>> f = Foo() 0314 >>> dir(f) 0315 ['ga', 'kan', 'roo'] 0316 0317 """ 0318 pass 0319 0320 def divmod(a,b): 0321 """ 0322 Take two (non complex) numbers as arguments and return a pair of numbers 0323 consisting of their quotient and remainder when using long division. With mixed 0324 operand types, the rules for binary arithmetic operators apply. For plain and 0325 long integers, the result is the same as ``(a // b, a % b)``. For floating point 0326 numbers the result is ``(q, a % b)``, where *q* is usually ``math.floor(a / b)`` 0327 but may be 1 less than that. In any case ``q * b + a % b`` is very close to 0328 *a*, if ``a % b`` is non-zero it has the same sign as *b*, and ``0 <= abs(a % b) 0329 < abs(b)``. 0330 0331 """ 0332 pass 0333 0334 def enumerate(sequence,start=0): 0335 """ 0336 Return an enumerate object. *sequence* must be a sequence, an 0337 :term:`iterator`, or some other object which supports iteration. The 0338 :meth:`!next` method of the iterator returned by :func:`enumerate` returns a 0339 tuple containing a count (from *start* which defaults to 0) and the 0340 corresponding value obtained from iterating over *iterable*. 0341 :func:`enumerate` is useful for obtaining an indexed series: ``(0, seq[0])``, 0342 ``(1, seq[1])``, ``(2, seq[2])``, more. For example: 0343 0344 >>> for i, season in enumerate(['Spring', 'Summer', 'Fall', 'Winter']): 0345 more print i, season 0346 0 Spring 0347 1 Summer 0348 2 Fall 0349 3 Winter 0350 0351 """ 0352 pass 0353 0354 def eval(expression,globals,locals): 0355 """ 0356 The arguments are a string and optional globals and locals. If provided, 0357 *globals* must be a dictionary. If provided, *locals* can be any mapping 0358 object. 0359 0360 """ 0361 pass 0362 0363 def execfile(filename,globals,locals): 0364 """ 0365 This function is similar to the :keyword:`exec` statement, but parses a file 0366 instead of a string. It is different from the :keyword:`import` statement in 0367 that it does not use the module administration --- it reads the file 0368 unconditionally and does not create a new module. [#]_ 0369 0370 The arguments are a file name and two optional dictionaries. The file is parsed 0371 and evaluated as a sequence of Python statements (similarly to a module) using 0372 the *globals* and *locals* dictionaries as global and local namespace. If 0373 provided, *locals* can be any mapping object. 0374 0375 """ 0376 pass 0377 0378 def file(filename,mode,bufsize): 0379 """ 0380 Constructor function for the :class:`file` type, described further in section 0381 :ref:`bltin-file-objects`. The constructor's arguments are the same as those 0382 of the :func:`open` built-in function described below. 0383 0384 When opening a file, it's preferable to use :func:`open` instead of invoking 0385 this constructor directly. :class:`file` is more suited to type testing (for 0386 example, writing ``isinstance(f, file)``). 0387 0388 """ 0389 pass 0390 0391 def filter(function,iterable): 0392 """ 0393 Construct a list from those elements of *iterable* for which *function* returns 0394 true. *iterable* may be either a sequence, a container which supports 0395 iteration, or an iterator. If *iterable* is a string or a tuple, the result 0396 also has that type; otherwise it is always a list. If *function* is ``None``, 0397 the identity function is assumed, that is, all elements of *iterable* that are 0398 false are removed. 0399 0400 Note that ``filter(function, iterable)`` is equivalent to ``[item for item in 0401 iterable if function(item)]`` if function is not ``None`` and ``[item for item 0402 in iterable if item]`` if function is ``None``. 0403 0404 See :func:`itertools.ifilter` and :func:`itertools.ifilterfalse` for iterator 0405 versions of this function, including a variation that filters for elements 0406 where the *function* returns false. 0407 0408 0409 """ 0410 pass 0411 0412 def float(x): 0413 """ 0414 Convert a string or a number to floating point. If the argument is a string, it 0415 must contain a possibly signed decimal or floating point number, possibly 0416 embedded in whitespace. The argument may also be [+|-]nan or [+|-]inf. 0417 Otherwise, the argument may be a plain or long integer 0418 or a floating point number, and a floating point number with the same value 0419 (within Python's floating point precision) is returned. If no argument is 0420 given, returns ``0.0``. 0421 0422 """ 0423 pass 0424 0425 def format(value,format_spec): 0426 """ 0427 """ 0428 pass 0429 0430 def frozenset(iterable): 0431 """:noindex: 0432 0433 Return a frozenset object, optionally with elements taken from *iterable*. 0434 The frozenset type is described in :ref:`types-set`. 0435 0436 For other containers see the built in :class:`dict`, :class:`list`, and 0437 :class:`tuple` classes, and the :mod:`collections` module. 0438 0439 """ 0440 pass 0441 0442 def getattr(object,name,default): 0443 """ 0444 Return the value of the named attribute of *object*. *name* must be a string. 0445 If the string is the name of one of the object's attributes, the result is the 0446 value of that attribute. For example, ``getattr(x, 'foobar')`` is equivalent to 0447 ``x.foobar``. If the named attribute does not exist, *default* is returned if 0448 provided, otherwise :exc:`AttributeError` is raised. 0449 0450 0451 """ 0452 pass 0453 0454 def globals(): 0455 """ 0456 Return a dictionary representing the current global symbol table. This is always 0457 the dictionary of the current module (inside a function or method, this is the 0458 module where it is defined, not the module from which it is called). 0459 0460 0461 """ 0462 pass 0463 0464 def hasattr(object,name): 0465 """ 0466 The arguments are an object and a string. The result is ``True`` if the string 0467 is the name of one of the object's attributes, ``False`` if not. (This is 0468 implemented by calling ``getattr(object, name)`` and seeing whether it raises an 0469 exception or not.) 0470 0471 0472 """ 0473 pass 0474 0475 def hash(object): 0476 """ 0477 Return the hash value of the object (if it has one). Hash values are integers. 0478 They are used to quickly compare dictionary keys during a dictionary lookup. 0479 Numeric values that compare equal have the same hash value (even if they are of 0480 different types, as is the case for 1 and 1.0). 0481 0482 0483 """ 0484 pass 0485 0486 def help(object): 0487 """ 0488 Invoke the built-in help system. (This function is intended for interactive 0489 use.) If no argument is given, the interactive help system starts on the 0490 interpreter console. If the argument is a string, then the string is looked up 0491 as the name of a module, function, class, method, keyword, or documentation 0492 topic, and a help page is printed on the console. If the argument is any other 0493 kind of object, a help page on the object is generated. 0494 0495 This function is added to the built-in namespace by the :mod:`site` module. 0496 0497 """ 0498 pass 0499 0500 def hex(x): 0501 """ 0502 Convert an integer number (of any size) to a hexadecimal string. The result is a 0503 valid Python expression. 0504 0505 """ 0506 pass 0507 0508 def id(object): 0509 """ 0510 Return the "identity" of an object. This is an integer (or long integer) which 0511 is guaranteed to be unique and constant for this object during its lifetime. 0512 Two objects with non-overlapping lifetimes may have the same :func:`id` 0513 value. 0514 0515 """ 0516 pass 0517 0518 def input(prompt): 0519 """ 0520 Equivalent to ``eval(raw_input(prompt))``. 0521 0522 """ 0523 pass 0524 0525 def int(x,base): 0526 """ 0527 Convert a string or number to a plain integer. If the argument is a string, 0528 it must contain a possibly signed decimal number representable as a Python 0529 integer, possibly embedded in whitespace. The *base* parameter gives the 0530 base for the conversion (which is 10 by default) and may be any integer in 0531 the range [2, 36], or zero. If *base* is zero, the proper radix is 0532 determined based on the contents of string; the interpretation is the same as 0533 for integer literals. (See :ref:`numbers`.) If *base* is specified and *x* 0534 is not a string, :exc:`TypeError` is raised. Otherwise, the argument may be a 0535 plain or long integer or a floating point number. Conversion of floating 0536 point numbers to integers truncates (towards zero). If the argument is 0537 outside the integer range a long object will be returned instead. If no 0538 arguments are given, returns ``0``. 0539 0540 The integer type is described in :ref:`typesnumeric`. 0541 0542 0543 """ 0544 pass 0545 0546 def isinstance(object,_classinfo): 0547 """ 0548 Return true if the *object* argument is an instance of the *classinfo* argument, 0549 or of a (direct or indirect) subclass thereof. Also return true if *classinfo* 0550 is a type object (new-style class) and *object* is an object of that type or of 0551 a (direct or indirect) subclass thereof. If *object* is not a class instance or 0552 an object of the given type, the function always returns false. If *classinfo* 0553 is neither a class object nor a type object, it may be a tuple of class or type 0554 objects, or may recursively contain other such tuples (other sequence types are 0555 not accepted). If *classinfo* is not a class, type, or tuple of classes, types, 0556 and such tuples, a :exc:`TypeError` exception is raised. 0557 0558 """ 0559 pass 0560 0561 def issub_class(_class,_classinfo): 0562 """ 0563 Return true if *class* is a subclass (direct or indirect) of *classinfo*. A 0564 class is considered a subclass of itself. *classinfo* may be a tuple of class 0565 objects, in which case every entry in *classinfo* will be checked. In any other 0566 case, a :exc:`TypeError` exception is raised. 0567 0568 """ 0569 pass 0570 0571 def iter(o,sentinel): 0572 """ 0573 Return an :term:`iterator` object. The first argument is interpreted very differently 0574 depending on the presence of the second argument. Without a second argument, *o* 0575 must be a collection object which supports the iteration protocol (the 0576 :meth:`__iter__` method), or it must support the sequence protocol (the 0577 :meth:`__getitem__` method with integer arguments starting at ``0``). If it 0578 does not support either of those protocols, :exc:`TypeError` is raised. If the 0579 second argument, *sentinel*, is given, then *o* must be a callable object. The 0580 iterator created in this case will call *o* with no arguments for each call to 0581 its :meth:`~iterator.next` method; if the value returned is equal to *sentinel*, 0582 :exc:`StopIteration` will be raised, otherwise the value will be returned. 0583 0584 One useful application of the second form of :func:`iter` is to read lines of 0585 a file until a certain line is reached. The following example reads a file 0586 until ``"STOP"`` is reached: :: 0587 0588 with open("mydata.txt") as fp: 0589 for line in iter(fp.readline, "STOP"): 0590 process_line(line) 0591 0592 """ 0593 pass 0594 0595 def len(s): 0596 """ 0597 Return the length (the number of items) of an object. The argument may be a 0598 sequence (string, tuple or list) or a mapping (dictionary). 0599 0600 0601 """ 0602 pass 0603 0604 def list(iterable): 0605 """ 0606 Return a list whose items are the same and in the same order as *iterable*'s 0607 items. *iterable* may be either a sequence, a container that supports 0608 iteration, or an iterator object. If *iterable* is already a list, a copy is 0609 made and returned, similar to ``iterable[:]``. For instance, ``list('abc')`` 0610 returns ``['a', 'b', 'c']`` and ``list( (1, 2, 3) )`` returns ``[1, 2, 3]``. If 0611 no argument is given, returns a new empty list, ``[]``. 0612 0613 :class:`list` is a mutable sequence type, as documented in 0614 :ref:`typesseq`. For other containers see the built in :class:`dict`, 0615 :class:`set`, and :class:`tuple` classes, and the :mod:`collections` module. 0616 0617 0618 """ 0619 pass 0620 0621 def locals(): 0622 """ 0623 Update and return a dictionary representing the current local symbol table. 0624 Free variables are returned by :func:`locals` when it is called in function 0625 blocks, but not in class blocks. 0626 0627 """ 0628 pass 0629 0630 def long(x,base): 0631 """ 0632 Convert a string or number to a long integer. If the argument is a string, it 0633 must contain a possibly signed number of arbitrary size, possibly embedded in 0634 whitespace. The *base* argument is interpreted in the same way as for 0635 :func:`int`, and may only be given when *x* is a string. Otherwise, the argument 0636 may be a plain or long integer or a floating point number, and a long integer 0637 with the same value is returned. Conversion of floating point numbers to 0638 integers truncates (towards zero). If no arguments are given, returns ``0L``. 0639 0640 The long type is described in :ref:`typesnumeric`. 0641 0642 0643 """ 0644 pass 0645 0646 def map(function,iterable,more): 0647 """ 0648 Apply *function* to every item of *iterable* and return a list of the results. 0649 If additional *iterable* arguments are passed, *function* must take that many 0650 arguments and is applied to the items from all iterables in parallel. If one 0651 iterable is shorter than another it is assumed to be extended with ``None`` 0652 items. If *function* is ``None``, the identity function is assumed; if there 0653 are multiple arguments, :func:`map` returns a list consisting of tuples 0654 containing the corresponding items from all iterables (a kind of transpose 0655 operation). The *iterable* arguments may be a sequence or any iterable object; 0656 the result is always a list. 0657 0658 0659 """ 0660 pass 0661 0662 def max(iterable,argsmorekey): 0663 """ 0664 With a single argument *iterable*, return the largest item of a non-empty 0665 iterable (such as a string, tuple or list). With more than one argument, return 0666 the largest of the arguments. 0667 0668 The optional *key* argument specifies a one-argument ordering function like that 0669 used for :meth:`list.sort`. The *key* argument, if supplied, must be in keyword 0670 form (for example, ``max(a,b,c,key=func)``). 0671 0672 """ 0673 pass 0674 0675 def memoryview(obj): 0676 """:noindex: 0677 0678 Return a "memory view" object created from the given argument. See 0679 :ref:`typememoryview` for more information. 0680 0681 0682 """ 0683 pass 0684 0685 def min(iterable,argsmorekey): 0686 """ 0687 With a single argument *iterable*, return the smallest item of a non-empty 0688 iterable (such as a string, tuple or list). With more than one argument, return 0689 the smallest of the arguments. 0690 0691 The optional *key* argument specifies a one-argument ordering function like that 0692 used for :meth:`list.sort`. The *key* argument, if supplied, must be in keyword 0693 form (for example, ``min(a,b,c,key=func)``). 0694 0695 """ 0696 pass 0697 0698 def next(iterator,default): 0699 """ 0700 Retrieve the next item from the *iterator* by calling its 0701 :meth:`~iterator.next` method. If *default* is given, it is returned if the 0702 iterator is exhausted, otherwise :exc:`StopIteration` is raised. 0703 0704 """ 0705 pass 0706 0707 def object(): 0708 """ 0709 Return a new featureless object. :class:`object` is a base for all new style 0710 classes. It has the methods that are common to all instances of new style 0711 classes. 0712 0713 """ 0714 pass 0715 0716 def oct(x): 0717 """ 0718 Convert an integer number (of any size) to an octal string. The result is a 0719 valid Python expression. 0720 0721 """ 0722 pass 0723 0724 def open(filename,mode,bufsize): 0725 """ 0726 Open a file, returning an object of the :class:`file` type described in 0727 section :ref:`bltin-file-objects`. If the file cannot be opened, 0728 :exc:`IOError` is raised. When opening a file, it's preferable to use 0729 :func:`open` instead of invoking the :class:`file` constructor directly. 0730 0731 The first two arguments are the same as for ``stdio``'s :cfunc:`fopen`: 0732 *filename* is the file name to be opened, and *mode* is a string indicating how 0733 the file is to be opened. 0734 0735 The most commonly-used values of *mode* are ``'r'`` for reading, ``'w'`` for 0736 writing (truncating the file if it already exists), and ``'a'`` for appending 0737 (which on *some* Unix systems means that *all* writes append to the end of the 0738 file regardless of the current seek position). If *mode* is omitted, it 0739 defaults to ``'r'``. The default is to use text mode, which may convert 0740 ``'\n'`` characters to a platform-specific representation on writing and back 0741 on reading. Thus, when opening a binary file, you should append ``'b'`` to 0742 the *mode* value to open the file in binary mode, which will improve 0743 portability. (Appending ``'b'`` is useful even on systems that don't treat 0744 binary and text files differently, where it serves as documentation.) See below 0745 for more possible values of *mode*. 0746 0747 """ 0748 pass 0749 0750 def ord(c): 0751 """ 0752 Given a string of length one, return an integer representing the Unicode code 0753 point of the character when the argument is a unicode object, or the value of 0754 the byte when the argument is an 8-bit string. For example, ``ord('a')`` returns 0755 the integer ``97``, ``ord(u'\u2020')`` returns ``8224``. This is the inverse of 0756 :func:`chr` for 8-bit strings and of :func:`unichr` for unicode objects. If a 0757 unicode argument is given and Python was built with UCS2 Unicode, then the 0758 character's code point must be in the range [0..65535] inclusive; otherwise the 0759 string length is two, and a :exc:`TypeError` will be raised. 0760 0761 0762 """ 0763 pass 0764 0765 def pow(x,y,z): 0766 """ 0767 Return *x* to the power *y*; if *z* is present, return *x* to the power *y*, 0768 modulo *z* (computed more efficiently than ``pow(x, y) % z``). The two-argument 0769 form ``pow(x, y)`` is equivalent to using the power operator: ``x**y``. 0770 0771 The arguments must have numeric types. With mixed operand types, the coercion 0772 rules for binary arithmetic operators apply. For int and long int operands, the 0773 result has the same type as the operands (after coercion) unless the second 0774 argument is negative; in that case, all arguments are converted to float and a 0775 float result is delivered. For example, ``10**2`` returns ``100``, but 0776 ``10**-2`` returns ``0.01``. (This last feature was added in Python 2.2. In 0777 Python 2.1 and before, if both arguments were of integer types and the second 0778 argument was negative, an exception was raised.) If the second argument is 0779 negative, the third argument must be omitted. If *z* is present, *x* and *y* 0780 must be of integer types, and *y* must be non-negative. (This restriction was 0781 added in Python 2.2. In Python 2.1 and before, floating 3-argument ``pow()`` 0782 returned platform-dependent results depending on floating-point rounding 0783 accidents.) 0784 0785 0786 """ 0787 pass 0788 0789 def property(fget,fset,fdel,doc): 0790 """ 0791 Return a property attribute for :term:`new-style class`\es (classes that 0792 derive from :class:`object`). 0793 0794 *fget* is a function for getting an attribute value, likewise *fset* is a 0795 function for setting, and *fdel* a function for del'ing, an attribute. Typical 0796 use is to define a managed attribute ``x``:: 0797 0798 class C(object): 0799 def __init__(self): 0800 self._x = None 0801 0802 def getx(self): 0803 return self._x 0804 def setx(self, value): 0805 self._x = value 0806 def delx(self): 0807 del self._x 0808 x = property(getx, setx, delx, "I'm the 'x' property.") 0809 0810 If then *c* is an instance of *C*, ``c.x`` will invoke the getter, 0811 ``c.x = value`` will invoke the setter and ``del c.x`` the deleter. 0812 0813 If given, *doc* will be the docstring of the property attribute. Otherwise, the 0814 property will copy *fget*'s docstring (if it exists). This makes it possible to 0815 create read-only properties easily using :func:`property` as a :term:`decorator`:: 0816 0817 class Parrot(object): 0818 def __init__(self): 0819 self._voltage = 100000 0820 0821 @property 0822 def voltage(self): 0823 " " " Get the current voltage. " " " 0824 return self._voltage 0825 0826 turns the :meth:`voltage` method into a "getter" for a read-only attribute 0827 with the same name. 0828 0829 A property object has :attr:`getter`, :attr:`setter`, and :attr:`deleter` 0830 methods usable as decorators that create a copy of the property with the 0831 corresponding accessor function set to the decorated function. This is 0832 best explained with an example:: 0833 0834 class C(object): 0835 def __init__(self): 0836 self._x = None 0837 0838 @property 0839 def x(self): 0840 " " " I'm the 'x' property. " " " 0841 return self._x 0842 0843 @x.setter 0844 def x(self, value): 0845 self._x = value 0846 0847 @x.deleter 0848 def x(self): 0849 del self._x 0850 0851 This code is exactly equivalent to the first example. Be sure to give the 0852 additional functions the same name as the original property (``x`` in this 0853 case.) 0854 0855 The returned property also has the attributes ``fget``, ``fset``, and 0856 ``fdel`` corresponding to the constructor arguments. 0857 0858 """ 0859 pass 0860 0861 def range(start,stop,step): 0862 """ 0863 This is a versatile function to create lists containing arithmetic progressions. 0864 It is most often used in :keyword:`for` loops. The arguments must be plain 0865 integers. If the *step* argument is omitted, it defaults to ``1``. If the 0866 *start* argument is omitted, it defaults to ``0``. The full form returns a list 0867 of plain integers ``[start, start + step, start + 2 * step, more]``. If *step* 0868 is positive, the last element is the largest ``start + i * step`` less than 0869 *stop*; if *step* is negative, the last element is the smallest ``start + i * 0870 step`` greater than *stop*. *step* must not be zero (or else :exc:`ValueError` 0871 is raised). Example: 0872 0873 >>> range(10) 0874 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 0875 >>> range(1, 11) 0876 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 0877 >>> range(0, 30, 5) 0878 [0, 5, 10, 15, 20, 25] 0879 >>> range(0, 10, 3) 0880 [0, 3, 6, 9] 0881 >>> range(0, -10, -1) 0882 [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] 0883 >>> range(0) 0884 [] 0885 >>> range(1, 0) 0886 [] 0887 0888 0889 """ 0890 pass 0891 0892 def raw_input(prompt): 0893 """ 0894 If the *prompt* argument is present, it is written to standard output without a 0895 trailing newline. The function then reads a line from input, converts it to a 0896 string (stripping a trailing newline), and returns that. When EOF is read, 0897 :exc:`EOFError` is raised. Example:: 0898 0899 >>> s = raw_input('--> ') 0900 --> Monty Python's Flying Circus 0901 >>> s 0902 "Monty Python's Flying Circus" 0903 0904 If the :mod:`readline` module was loaded, then :func:`raw_input` will use it to 0905 provide elaborate line editing and history features. 0906 0907 0908 """ 0909 pass 0910 0911 def reduce(function,iterable,initializer): 0912 """ 0913 Apply *function* of two arguments cumulatively to the items of *iterable*, from 0914 left to right, so as to reduce the iterable to a single value. For example, 0915 ``reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])`` calculates ``((((1+2)+3)+4)+5)``. 0916 The left argument, *x*, is the accumulated value and the right argument, *y*, is 0917 the update value from the *iterable*. If the optional *initializer* is present, 0918 it is placed before the items of the iterable in the calculation, and serves as 0919 a default when the iterable is empty. If *initializer* is not given and 0920 *iterable* contains only one item, the first item is returned. 0921 0922 0923 """ 0924 pass 0925 0926 def reload(module): 0927 """ 0928 Reload a previously imported *module*. The argument must be a module object, so 0929 it must have been successfully imported before. This is useful if you have 0930 edited the module source file using an external editor and want to try out the 0931 new version without leaving the Python interpreter. The return value is the 0932 module object (the same as the *module* argument). 0933 0934 When ``reload(module)`` is executed: 0935 0936 * Python modules' code is recompiled and the module-level code reexecuted, 0937 defining a new set of objects which are bound to names in the module's 0938 dictionary. The ``init`` function of extension modules is not called a second 0939 time. 0940 0941 * As with all other objects in Python the old objects are only reclaimed after 0942 their reference counts drop to zero. 0943 0944 * The names in the module namespace are updated to point to any new or changed 0945 objects. 0946 0947 * Other references to the old objects (such as names external to the module) are 0948 not rebound to refer to the new objects and must be updated in each namespace 0949 where they occur if that is desired. 0950 0951 There are a number of other caveats: 0952 0953 If a module is syntactically correct but its initialization fails, the first 0954 :keyword:`import` statement for it does not bind its name locally, but does 0955 store a (partially initialized) module object in ``sys.modules``. To reload the 0956 module you must first :keyword:`import` it again (this will bind the name to the 0957 partially initialized module object) before you can :func:`reload` it. 0958 0959 When a module is reloaded, its dictionary (containing the module's global 0960 variables) is retained. Redefinitions of names will override the old 0961 definitions, so this is generally not a problem. If the new version of a module 0962 does not define a name that was defined by the old version, the old definition 0963 remains. This feature can be used to the module's advantage if it maintains a 0964 global table or cache of objects --- with a :keyword:`try` statement it can test 0965 for the table's presence and skip its initialization if desired:: 0966 0967 try: 0968 cache 0969 except NameError: 0970 cache = {} 0971 0972 It is legal though generally not very useful to reload built-in or dynamically 0973 loaded modules, except for :mod:`sys`, :mod:`__main__` and :mod:`__builtin__`. 0974 In many cases, however, extension modules are not designed to be initialized 0975 more than once, and may fail in arbitrary ways when reloaded. 0976 0977 If a module imports objects from another module using :keyword:`from` more 0978 :keyword:`import` more, calling :func:`reload` for the other module does not 0979 redefine the objects imported from it --- one way around this is to re-execute 0980 the :keyword:`from` statement, another is to use :keyword:`import` and qualified 0981 names (*module*.*name*) instead. 0982 0983 If a module instantiates instances of a class, reloading the module that defines 0984 the class does not affect the method definitions of the instances --- they 0985 continue to use the old class definition. The same is true for derived classes. 0986 0987 0988 """ 0989 pass 0990 0991 def repr(object): 0992 """ 0993 Return a string containing a printable representation of an object. This is 0994 the same value yielded by conversions (reverse quotes). It is sometimes 0995 useful to be able to access this operation as an ordinary function. For many 0996 types, this function makes an attempt to return a string that would yield an 0997 object with the same value when passed to :func:`eval`, otherwise the 0998 representation is a string enclosed in angle brackets that contains the name 0999 of the type of the object together with additional information often 1000 including the name and address of the object. A class can control what this 1001 function returns for its instances by defining a :meth:`__repr__` method. 1002 1003 1004 """ 1005 pass 1006 1007 def reversed(seq): 1008 """ 1009 Return a reverse :term:`iterator`. *seq* must be an object which has 1010 a :meth:`__reversed__` method or supports the sequence protocol (the 1011 :meth:`__len__` method and the :meth:`__getitem__` method with integer 1012 arguments starting at ``0``). 1013 1014 """ 1015 pass 1016 1017 def round(x,n): 1018 """ 1019 Return the floating point value *x* rounded to *n* digits after the decimal 1020 point. If *n* is omitted, it defaults to zero. The result is a floating point 1021 number. Values are rounded to the closest multiple of 10 to the power minus 1022 *n*; if two multiples are equally close, rounding is done away from 0 (so. for 1023 example, ``round(0.5)`` is ``1.0`` and ``round(-0.5)`` is ``-1.0``). 1024 1025 1026 """ 1027 pass 1028 1029 def set(iterable): 1030 """:noindex: 1031 1032 Return a new set, optionally with elements taken from *iterable*. 1033 The set type is described in :ref:`types-set`. 1034 1035 For other containers see the built in :class:`dict`, :class:`list`, and 1036 :class:`tuple` classes, and the :mod:`collections` module. 1037 1038 """ 1039 pass 1040 1041 def setattr(object,name,value): 1042 """ 1043 This is the counterpart of :func:`getattr`. The arguments are an object, a 1044 string and an arbitrary value. The string may name an existing attribute or a 1045 new attribute. The function assigns the value to the attribute, provided the 1046 object allows it. For example, ``setattr(x, 'foobar', 123)`` is equivalent to 1047 ``x.foobar = 123``. 1048 1049 1050 """ 1051 pass 1052 1053 def slice(start,stop,step): 1054 """ 1055 """ 1056 pass 1057 1058 def sorted(iterable,cmp,key,reverse): 1059 """ 1060 Return a new sorted list from the items in *iterable*. 1061 1062 The optional arguments *cmp*, *key*, and *reverse* have the same meaning as 1063 those for the :meth:`list.sort` method (described in section 1064 :ref:`typesseq-mutable`). 1065 1066 *cmp* specifies a custom comparison function of two arguments (iterable 1067 elements) which should return a negative, zero or positive number depending on 1068 whether the first argument is considered smaller than, equal to, or larger than 1069 the second argument: ``cmp=lambda x,y: cmp(x.lower(), y.lower())``. The default 1070 value is ``None``. 1071 1072 *key* specifies a function of one argument that is used to extract a comparison 1073 key from each list element: ``key=str.lower``. The default value is ``None`` 1074 (compare the elements directly). 1075 1076 *reverse* is a boolean value. If set to ``True``, then the list elements are 1077 sorted as if each comparison were reversed. 1078 1079 In general, the *key* and *reverse* conversion processes are much faster 1080 than specifying an equivalent *cmp* function. This is because *cmp* is 1081 called multiple times for each list element while *key* and *reverse* touch 1082 each element only once. Use :func:`functools.cmp_to_key` to convert an 1083 old-style *cmp* function to a *key* function. 1084 1085 For sorting examples and a brief sorting tutorial, see `Sorting HowTo 1086 <http://wiki.python.org/moin/HowTo/Sorting/>`_\. 1087 1088 """ 1089 pass 1090 1091 def staticmethod(function): 1092 """ 1093 Return a static method for *function*. 1094 1095 A static method does not receive an implicit first argument. To declare a static 1096 method, use this idiom:: 1097 1098 class C: 1099 @staticmethod 1100 def f(arg1, arg2, more): more 1101 1102 The ``@staticmethod`` form is a function :term:`decorator` -- see the 1103 description of function definitions in :ref:`function` for details. 1104 1105 It can be called either on the class (such as ``C.f()``) or on an instance (such 1106 as ``C().f()``). The instance is ignored except for its class. 1107 1108 Static methods in Python are similar to those found in Java or C++. For a more 1109 advanced concept, see :func:`classmethod` in this section. 1110 1111 For more information on static methods, consult the documentation on the 1112 standard type hierarchy in :ref:`types`. 1113 1114 """ 1115 pass 1116 1117 def str(object): 1118 """ 1119 Return a string containing a nicely printable representation of an object. For 1120 strings, this returns the string itself. The difference with ``repr(object)`` 1121 is that ``str(object)`` does not always attempt to return a string that is 1122 acceptable to :func:`eval`; its goal is to return a printable string. If no 1123 argument is given, returns the empty string, ``''``. 1124 1125 For more information on strings see :ref:`typesseq` which describes sequence 1126 functionality (strings are sequences), and also the string-specific methods 1127 described in the :ref:`string-methods` section. To output formatted strings 1128 use template strings or the ``%`` operator described in the 1129 :ref:`string-formatting` section. In addition see the :ref:`stringservices` 1130 section. See also :func:`unicode`. 1131 1132 1133 """ 1134 pass 1135 1136 def sum(iterable,start): 1137 """ 1138 Sums *start* and the items of an *iterable* from left to right and returns the 1139 total. *start* defaults to ``0``. The *iterable*'s items are normally numbers, 1140 and the start value is not allowed to be a string. 1141 1142 For some use cases, there are good alternatives to :func:`sum`. 1143 The preferred, fast way to concatenate a sequence of strings is by calling 1144 ``''.join(sequence)``. To add floating point values with extended precision, 1145 see :func:`math.fsum`\. To concatenate a series of iterables, consider using 1146 :func:`itertools.chain`. 1147 1148 """ 1149 pass 1150 1151 def super(type,object_or_type): 1152 """ 1153 Return a proxy object that delegates method calls to a parent or sibling 1154 class of *type*. This is useful for accessing inherited methods that have 1155 been overridden in a class. The search order is same as that used by 1156 :func:`getattr` except that the *type* itself is skipped. 1157 1158 The :attr:`__mro__` attribute of the *type* lists the method resolution 1159 search order used by both :func:`getattr` and :func:`super`. The attribute 1160 is dynamic and can change whenever the inheritance hierarchy is updated. 1161 1162 If the second argument is omitted, the super object returned is unbound. If 1163 the second argument is an object, ``isinstance(obj, type)`` must be true. If 1164 the second argument is a type, ``issubclass(type2, type)`` must be true (this 1165 is useful for classmethods). 1166 1167 """ 1168 pass 1169 1170 def tuple(iterable): 1171 """ 1172 Return a tuple whose items are the same and in the same order as *iterable*'s 1173 items. *iterable* may be a sequence, a container that supports iteration, or an 1174 iterator object. If *iterable* is already a tuple, it is returned unchanged. 1175 For instance, ``tuple('abc')`` returns ``('a', 'b', 'c')`` and ``tuple([1, 2, 1176 3])`` returns ``(1, 2, 3)``. If no argument is given, returns a new empty 1177 tuple, ``()``. 1178 1179 :class:`tuple` is an immutable sequence type, as documented in 1180 :ref:`typesseq`. For other containers see the built in :class:`dict`, 1181 :class:`list`, and :class:`set` classes, and the :mod:`collections` module. 1182 1183 1184 """ 1185 pass 1186 1187 def type(object): 1188 """ 1189 """ 1190 pass 1191 1192 def type(name,bases,dict): 1193 """:noindex: 1194 1195 Return a new type object. This is essentially a dynamic form of the 1196 :keyword:`class` statement. The *name* string is the class name and becomes the 1197 :attr:`__name__` attribute; the *bases* tuple itemizes the base classes and 1198 becomes the :attr:`__bases__` attribute; and the *dict* dictionary is the 1199 namespace containing definitions for class body and becomes the :attr:`__dict__` 1200 attribute. For example, the following two statements create identical 1201 :class:`type` objects: 1202 1203 >>> class X(object): 1204 more a = 1 1205 more 1206 >>> X = type('X', (object,), dict(a=1)) 1207 1208 """ 1209 pass 1210 1211 def unichr(i): 1212 """ 1213 Return the Unicode string of one character whose Unicode code is the integer 1214 *i*. For example, ``unichr(97)`` returns the string ``u'a'``. This is the 1215 inverse of :func:`ord` for Unicode strings. The valid range for the argument 1216 depends how Python was configured -- it may be either UCS2 [0..0xFFFF] or UCS4 1217 [0..0x10FFFF]. :exc:`ValueError` is raised otherwise. For ASCII and 8-bit 1218 strings see :func:`chr`. 1219 1220 """ 1221 pass 1222 1223 def unicode(object,encoding,errors): 1224 """ 1225 Return the Unicode string version of *object* using one of the following modes: 1226 1227 If *encoding* and/or *errors* are given, ``unicode()`` will decode the object 1228 which can either be an 8-bit string or a character buffer using the codec for 1229 *encoding*. The *encoding* parameter is a string giving the name of an encoding; 1230 if the encoding is not known, :exc:`LookupError` is raised. Error handling is 1231 done according to *errors*; this specifies the treatment of characters which are 1232 invalid in the input encoding. If *errors* is ``'strict'`` (the default), a 1233 :exc:`ValueError` is raised on errors, while a value of ``'ignore'`` causes 1234 errors to be silently ignored, and a value of ``'replace'`` causes the official 1235 Unicode replacement character, ``U+FFFD``, to be used to replace input 1236 characters which cannot be decoded. See also the :mod:`codecs` module. 1237 1238 If no optional parameters are given, ``unicode()`` will mimic the behaviour of 1239 ``str()`` except that it returns Unicode strings instead of 8-bit strings. More 1240 precisely, if *object* is a Unicode string or subclass it will return that 1241 Unicode string without any additional decoding applied. 1242 1243 For objects which provide a :meth:`__unicode__` method, it will call this method 1244 without arguments to create a Unicode string. For all other objects, the 8-bit 1245 string version or representation is requested and then converted to a Unicode 1246 string using the codec for the default encoding in ``'strict'`` mode. 1247 1248 For more information on Unicode strings see :ref:`typesseq` which describes 1249 sequence functionality (Unicode strings are sequences), and also the 1250 string-specific methods described in the :ref:`string-methods` section. To 1251 output formatted strings use template strings or the ``%`` operator described 1252 in the :ref:`string-formatting` section. In addition see the 1253 :ref:`stringservices` section. See also :func:`str`. 1254 1255 """ 1256 pass 1257 1258 def vars(object): 1259 """ 1260 Without an argument, act like :func:`locals`. 1261 1262 With a module, class or class instance object as argument (or anything else that 1263 has a :attr:`__dict__` attribute), return that attribute. 1264 1265 """ 1266 pass 1267 1268 def xrange(start,stop,step): 1269 """ 1270 This function is very similar to :func:`range`, but returns an "xrange object" 1271 instead of a list. This is an opaque sequence type which yields the same values 1272 as the corresponding list, without actually storing them all simultaneously. 1273 The advantage of :func:`xrange` over :func:`range` is minimal (since 1274 :func:`xrange` still has to create the values when asked for them) except when a 1275 very large range is used on a memory-starved machine or when all of the range's 1276 elements are never used (such as when the loop is usually terminated with 1277 :keyword:`break`). 1278 1279 """ 1280 pass 1281 1282 def zip(iterable,more): 1283 """ 1284 This function returns a list of tuples, where the *i*-th tuple contains the 1285 *i*-th element from each of the argument sequences or iterables. The returned 1286 list is truncated in length to the length of the shortest argument sequence. 1287 When there are multiple arguments which are all of the same length, :func:`zip` 1288 is similar to :func:`map` with an initial argument of ``None``. With a single 1289 sequence argument, it returns a list of 1-tuples. With no arguments, it returns 1290 an empty list. 1291 1292 The left-to-right evaluation order of the iterables is guaranteed. This 1293 makes possible an idiom for clustering a data series into n-length groups 1294 using ``zip(*[iter(s)]*n)``. 1295 1296 :func:`zip` in conjunction with the ``*`` operator can be used to unzip a 1297 list:: 1298 1299 >>> x = [1, 2, 3] 1300 >>> y = [4, 5, 6] 1301 >>> zipped = zip(x, y) 1302 >>> zipped 1303 [(1, 4), (2, 5), (3, 6)] 1304 >>> x2, y2 = zip(*zipped) 1305 >>> x == list(x2) and y == list(y2) 1306 True 1307 1308 """ 1309 pass 1310 1311 def __import__(name,globals,locals,_fromlist,level): 1312 """ 1313 """ 1314 pass 1315 1316 def apply(function,args,keywords): 1317 """ 1318 The *function* argument must be a callable object (a user-defined or built-in 1319 function or method, or a class object) and the *args* argument must be a 1320 sequence. The *function* is called with *args* as the argument list; the number 1321 of arguments is the length of the tuple. If the optional *keywords* argument is 1322 present, it must be a dictionary whose keys are strings. It specifies keyword 1323 arguments to be added to the end of the argument list. Calling :func:`apply` is 1324 different from just calling ``function(args)``, since in that case there is 1325 always exactly one argument. The use of :func:`apply` is equivalent to 1326 ``function(*args, **keywords)``. 1327 1328 """ 1329 pass 1330 1331 def buffer(object,offset,size): 1332 """ 1333 The *object* argument must be an object that supports the buffer call interface 1334 (such as strings, arrays, and buffers). A new buffer object will be created 1335 which references the *object* argument. The buffer object will be a slice from 1336 the beginning of *object* (or from the specified *offset*). The slice will 1337 extend to the end of *object* (or will have a length given by the *size* 1338 argument). 1339 1340 1341 """ 1342 pass 1343 1344 def coerce(x,y): 1345 """ 1346 Return a tuple consisting of the two numeric arguments converted to a common 1347 type, using the same rules as used by arithmetic operations. If coercion is not 1348 possible, raise :exc:`TypeError`. 1349 1350 1351 """ 1352 pass 1353 1354 def intern(string): 1355 """ 1356 Enter *string* in the table of "interned" strings and return the interned string 1357 -- which is *string* itself or a copy. Interning strings is useful to gain a 1358 little performance on dictionary lookup -- if the keys in a dictionary are 1359 interned, and the lookup key is interned, the key comparisons (after hashing) 1360 can be done by a pointer compare instead of a string compare. Normally, the 1361 names used in Python programs are automatically interned, and the dictionaries 1362 used to hold module, class or instance attributes have interned keys. 1363 1364 """ 1365 pass 1366