File indexing completed on 2024-04-28 15:53:57

0001 #!/usr/bin/env python2.7
0002 # -*- coding: utf-8 -*-
0003 """
0004 .. *************
0005 Built-in Types
0006 **************
0007 
0008 The following sections describe the standard types that are built into the
0009 interpreter.
0010 
0011 """
0012 class set:
0013 
0014 
0015     """frozenset([iterable])
0016     
0017     Return a new set or frozenset object whose elements are taken from
0018     *iterable*.  The elements of a set must be hashable.  To represent sets of
0019     sets, the inner sets must be :class:`frozenset` objects.  If *iterable* is
0020     not specified, a new empty set is returned.
0021     
0022     Instances of :class:`set` and :class:`frozenset` provide the following
0023     operations:
0024     
0025     """
0026     
0027     
0028     def __init__(self, ):
0029         pass
0030     
0031     def isdisjoint(self, other):
0032         """
0033         Return True if the set has no elements in common with *other*.  Sets are
0034         disjoint if and only if their intersection is the empty set.
0035         
0036         """
0037         pass
0038         
0039     def issubset(self, other):
0040         """set <= other
0041         
0042         Test whether every element in the set is in *other*.
0043         
0044         """
0045         pass
0046         
0047     def set"other(self, ():
0048         """
0049         Test whether the set is a true subset of *other*, that is,
0050         ``set <= other and set != other``.
0051         
0052         """
0053         pass
0054         
0055     def issuperset(self, other):
0056         """set >= other
0057         
0058         Test whether every element in *other* is in the set.
0059         
0060         """
0061         pass
0062         
0063     def set"other(self, ():
0064         """
0065         Test whether the set is a true superset of *other*, that is, ``set >=
0066         other and set != other``.
0067         
0068         """
0069         pass
0070         
0071     def union(self, other,more):
0072         """set | other | more
0073         
0074         Return a new set with elements from the set and all others.
0075         
0076         """
0077         pass
0078         
0079     def intersection(self, other,more):
0080         """set & other & more
0081         
0082         Return a new set with elements common to the set and all others.
0083         
0084         """
0085         pass
0086         
0087     def difference(self, other,more):
0088         """set - other - more
0089         
0090         Return a new set with elements in the set that are not in the others.
0091         
0092         """
0093         pass
0094         
0095     def symmetric_difference(self, other):
0096         """set ^ other
0097         
0098         Return a new set with elements in either the set or *other* but not both.
0099         
0100         """
0101         pass
0102         
0103     def copy(self, ):
0104         """
0105         Return a new set with a shallow copy of *s*.
0106         
0107         
0108         Note, the non-operator versions of :meth:`union`, :meth:`intersection`,
0109         :meth:`difference`, and :meth:`symmetric_difference`, :meth:`issubset`, and
0110         :meth:`issuperset` methods will accept any iterable as an argument.  In
0111         contrast, their operator based counterparts require their arguments to be
0112         sets.  This precludes error-prone constructions like ``set('abc') & 'cbs'``
0113         in favor of the more readable ``set('abc').intersection('cbs')``.
0114         
0115         Both :class:`set` and :class:`frozenset` support set to set comparisons. Two
0116         sets are equal if and only if every element of each set is contained in the
0117         other (each is a subset of the other). A set is less than another set if and
0118         only if the first set is a proper subset of the second set (is a subset, but
0119         is not equal). A set is greater than another set if and only if the first set
0120         is a proper superset of the second set (is a superset, but is not equal).
0121         
0122         Instances of :class:`set` are compared to instances of :class:`frozenset`
0123         based on their members.  For example, ``set('abc') == frozenset('abc')``
0124         returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``.
0125         
0126         The subset and equality comparisons do not generalize to a complete ordering
0127         function.  For example, any two disjoint sets are not equal and are not
0128         subsets of each other, so *all* of the following return ``False``: ``a<b``,
0129         ``a==b``, or ``a>b``. Accordingly, sets do not implement the :meth:`__cmp__`
0130         method.
0131         
0132         Since sets only define partial ordering (subset relationships), the output of
0133         the :meth:`list.sort` method is undefined for lists of sets.
0134         
0135         Set elements, like dictionary keys, must be :term:`hashable`.
0136         
0137         Binary operations that mix :class:`set` instances with :class:`frozenset`
0138         return the type of the first operand.  For example: ``frozenset('ab') |
0139         set('bc')`` returns an instance of :class:`frozenset`.
0140         
0141         The following table lists operations available for :class:`set` that do not
0142         apply to immutable instances of :class:`frozenset`:
0143         
0144         """
0145         pass
0146         
0147     def update(self, other,more):
0148         """set |= other | more
0149         
0150         Update the set, adding elements from all others.
0151         
0152         """
0153         pass
0154         
0155     def intersection_update(self, other,more):
0156         """set &= other & more
0157         
0158         Update the set, keeping only elements found in it and all others.
0159         
0160         """
0161         pass
0162         
0163     def difference_update(self, other,more):
0164         """set -= other | more
0165         
0166         Update the set, removing elements found in others.
0167         
0168         """
0169         pass
0170         
0171     def symmetric_difference_update(self, other):
0172         """set ^= other
0173         
0174         Update the set, keeping only elements found in either set, but not in both.
0175         
0176         """
0177         pass
0178         
0179     def add(self, elem):
0180         """
0181         Add element *elem* to the set.
0182         
0183         """
0184         pass
0185         
0186     def remove(self, elem):
0187         """
0188         Remove element *elem* from the set.  Raises :exc:`KeyError` if *elem* is
0189         not contained in the set.
0190         
0191         """
0192         pass
0193         
0194     def discard(self, elem):
0195         """
0196         Remove element *elem* from the set if it is present.
0197         
0198         """
0199         pass
0200         
0201     def pop(self, ):
0202         """
0203         Remove and return an arbitrary element from the set.  Raises
0204         :exc:`KeyError` if the set is empty.
0205         
0206         """
0207         pass
0208         
0209     def clear(self, ):
0210         """
0211         Remove all elements from the set.
0212         
0213         
0214         Note, the non-operator versions of the :meth:`update`,
0215         :meth:`intersection_update`, :meth:`difference_update`, and
0216         :meth:`symmetric_difference_update` methods will accept any iterable as an
0217         argument.
0218         
0219         Note, the *elem* argument to the :meth:`__contains__`, :meth:`remove`, and
0220         :meth:`discard` methods may be a set.  To support searching for an equivalent
0221         frozenset, the *elem* set is temporarily mutated during the search and then
0222         restored.  During the search, the *elem* set should not be read or mutated
0223         since it does not have a meaningful value.
0224         
0225         
0226         """
0227         pass
0228         
0229     
0230 
0231 
0232 class dict:
0233 
0234 
0235     """
0236     Return a new dictionary initialized from an optional positional argument or from
0237     a set of keyword arguments. If no arguments are given, return a new empty
0238     dictionary. If the positional argument *arg* is a mapping object, return a
0239     dictionary mapping the same keys to the same values as does the mapping object.
0240     Otherwise the positional argument must be a sequence, a container that supports
0241     iteration, or an iterator object.  The elements of the argument must each also
0242     be of one of those kinds, and each must in turn contain exactly two objects.
0243     The first is used as a key in the new dictionary, and the second as the key's
0244     value.  If a given key is seen more than once, the last value associated with it
0245     is retained in the new dictionary.
0246     
0247     If keyword arguments are given, the keywords themselves with their associated
0248     values are added as items to the dictionary. If a key is specified both in the
0249     positional argument and as a keyword argument, the value associated with the
0250     keyword is retained in the dictionary. For example, these all return a
0251     dictionary equal to ``{"one": 1, "two": 2}``:
0252     
0253     * ``dict(one=1, two=2)``
0254     * ``dict({'one': 1, 'two': 2})``
0255     * ``dict(zip(('one', 'two'), (1, 2)))``
0256     * ``dict([['two', 2], ['one', 1]])``
0257     
0258     The first example only works for keys that are valid Python
0259     identifiers; the others work with any valid keys.
0260     
0261     """
0262     
0263     
0264     def __init__(self, ):
0265         pass
0266     
0267     def clear(self, ):
0268         """
0269         Remove all items from the dictionary.
0270         
0271         """
0272         pass
0273         
0274     def copy(self, ):
0275         """
0276         Return a shallow copy of the dictionary.
0277         
0278         """
0279         pass
0280         
0281     def _fromkeys(self, seq,value):
0282         """
0283         Create a new dictionary with keys from *seq* and values set to *value*.
0284         
0285         :func:`fromkeys` is a class method that returns a new dictionary. *value*
0286         defaults to ``None``.
0287         
0288         """
0289         pass
0290         
0291     def get(self, key,default):
0292         """
0293         Return the value for *key* if *key* is in the dictionary, else *default*.
0294         If *default* is not given, it defaults to ``None``, so that this method
0295         never raises a :exc:`KeyError`.
0296         
0297         """
0298         pass
0299         
0300     def has_key(self, key):
0301         """
0302         Test for the presence of *key* in the dictionary.  :meth:`has_key` is
0303         deprecated in favor of ``key in d``.
0304         
0305         """
0306         pass
0307         
0308     def items(self, ):
0309         """
0310         Return a copy of the dictionary's list of ``(key, value)`` pairs.
0311         
0312         """
0313         pass
0314         
0315     def iteritems(self, ):
0316         """
0317         Return an iterator over the dictionary's ``(key, value)`` pairs.  See the
0318         note for :meth:`dict.items`.
0319         
0320         Using :meth:`iteritems` while adding or deleting entries in the dictionary
0321         may raise a :exc:`RuntimeError` or fail to iterate over all entries.
0322         
0323         """
0324         pass
0325         
0326     def iterkeys(self, ):
0327         """
0328         Return an iterator over the dictionary's keys.  See the note for
0329         :meth:`dict.items`.
0330         
0331         Using :meth:`iterkeys` while adding or deleting entries in the dictionary
0332         may raise a :exc:`RuntimeError` or fail to iterate over all entries.
0333         
0334         """
0335         pass
0336         
0337     def itervalues(self, ):
0338         """
0339         Return an iterator over the dictionary's values.  See the note for
0340         :meth:`dict.items`.
0341         
0342         Using :meth:`itervalues` while adding or deleting entries in the
0343         dictionary may raise a :exc:`RuntimeError` or fail to iterate over all
0344         entries.
0345         
0346         """
0347         pass
0348         
0349     def keys(self, ):
0350         """
0351         Return a copy of the dictionary's list of keys.  See the note for
0352         :meth:`dict.items`.
0353         
0354         """
0355         pass
0356         
0357     def pop(self, key,default):
0358         """
0359         If *key* is in the dictionary, remove it and return its value, else return
0360         *default*.  If *default* is not given and *key* is not in the dictionary,
0361         a :exc:`KeyError` is raised.
0362         
0363         """
0364         pass
0365         
0366     def popitem(self, ):
0367         """
0368         Remove and return an arbitrary ``(key, value)`` pair from the dictionary.
0369         
0370         :func:`popitem` is useful to destructively iterate over a dictionary, as
0371         often used in set algorithms.  If the dictionary is empty, calling
0372         :func:`popitem` raises a :exc:`KeyError`.
0373         
0374         """
0375         pass
0376         
0377     def setdefault(self, key,default):
0378         """
0379         If *key* is in the dictionary, return its value.  If not, insert *key*
0380         with a value of *default* and return *default*.  *default* defaults to
0381         ``None``.
0382         
0383         """
0384         pass
0385         
0386     def update(self, other):
0387         """
0388         Update the dictionary with the key/value pairs from *other*, overwriting
0389         existing keys.  Return ``None``.
0390         
0391         :func:`update` accepts either another dictionary object or an iterable of
0392         key/value pairs (as tuples or other iterables of length two).  If keyword
0393         arguments are specified, the dictionary is then updated with those
0394         key/value pairs: ``d.update(red=1, blue=2)``.
0395         
0396         """
0397         pass
0398         
0399     def values(self, ):
0400         """
0401         Return a copy of the dictionary's list of values.  See the note for
0402         :meth:`dict.items`.
0403         
0404         """
0405         pass
0406         
0407     def viewitems(self, ):
0408         """
0409         Return a new view of the dictionary's items (``(key, value)`` pairs).  See
0410         below for documentation of view objects.
0411         
0412         """
0413         pass
0414         
0415     def viewkeys(self, ):
0416         """
0417         Return a new view of the dictionary's keys.  See below for documentation of
0418         view objects.
0419         
0420         """
0421         pass
0422         
0423     def viewvalues(self, ):
0424         """
0425         Return a new view of the dictionary's values.  See below for documentation of
0426         view objects.
0427         
0428         """
0429         pass
0430         
0431     
0432 
0433 
0434 class memoryview:
0435 
0436 
0437     """
0438     Create a :class:`memoryview` that references *obj*.  *obj* must support the
0439     buffer protocol.  Built-in objects that support the buffer protocol include
0440     :class:`str` and :class:`bytearray` (but not :class:`unicode`).
0441     
0442     A :class:`memoryview` has the notion of an *element*, which is the
0443     atomic memory unit handled by the originating object *obj*.  For many
0444     simple types such as :class:`str` and :class:`bytearray`, an element
0445     is a single byte, but other third-party types may expose larger elements.
0446     
0447     ``len(view)`` returns the total number of elements in the memoryview,
0448     *view*.  The :class:`~memoryview.itemsize` attribute will give you the
0449     number of bytes in a single element.
0450     
0451     A :class:`memoryview` supports slicing to expose its data.  Taking a single
0452     index will return a single element as a :class:`str` object.  Full
0453     slicing will result in a subview::
0454     
0455     >>> v = memoryview('abcefg')
0456     >>> v[1]
0457     'b'
0458     >>> v[-1]
0459     'g'
0460     >>> v[1:4]
0461     <memory at 0x77ab28>
0462     >>> v[1:4].tobytes()
0463     'bce'
0464     
0465     If the object the memoryview is over supports changing its data, the
0466     memoryview supports slice assignment::
0467     
0468     >>> data = bytearray('abcefg')
0469     >>> v = memoryview(data)
0470     >>> v.readonly
0471     False
0472     >>> v[0] = 'z'
0473     >>> data
0474     bytearray(b'zbcefg')
0475     >>> v[1:4] = '123'
0476     >>> data
0477     bytearray(b'z123fg')
0478     >>> v[2] = 'spam'
0479     Traceback (most recent call last):
0480     File "<stdin>", line 1, in <module>
0481     ValueError: cannot modify size of memoryview object
0482     
0483     Notice how the size of the memoryview object cannot be changed.
0484     
0485     :class:`memoryview` has two methods:
0486     
0487     """
0488     
0489     
0490     def __init__(self, ):
0491         pass
0492     
0493     def tobytes(self, ):
0494         """
0495         Return the data in the buffer as a bytestring (an object of class
0496         :class:`str`). ::
0497         
0498         >>> m = memoryview("abc")
0499         >>> m.tobytes()
0500         'abc'
0501         
0502         """
0503         pass
0504         
0505     def tolist(self, ):
0506         """
0507         Return the data in the buffer as a list of integers. ::
0508         
0509         >>> memoryview("abc").tolist()
0510         [97, 98, 99]
0511         
0512         There are also several readonly attributes available:
0513         
0514         """
0515         pass
0516         
0517     
0518 
0519