💾 Archived View for tris.fyi › pydoc › _collections_abc captured on 2023-01-29 at 02:53:26. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-07-16)

🚧 View Differences

-=-=-=-=-=-=-

Back to module index

Go to module by name

_collections_abc

Abstract Base Classes (ABCs) for collections, according to PEP 3119.

Unit tests are in test_collections.

Classes

ABCMeta

Metaclass for defining Abstract Base Classes (ABCs).

        Use this metaclass to create an ABC.  An ABC can be subclassed
        directly, and then acts as a mix-in class.  You can also register
        unrelated concrete classes (even built-in classes) and unrelated
        ABCs as 'virtual subclasses' -- these and their descendants will
        be considered subclasses of the registering ABC by the built-in
        issubclass() function, but the registering ABC won't show up in
        their MRO (Method Resolution Order) nor will method
        implementations defined by the registering ABC be callable (not
        even via super()).
        
mro(self, /)

  Return a type's method resolution order.
register(cls, subclass)

  Register a virtual subclass of an ABC.

              Returns the subclass, to allow usage as a class decorator.
            

AsyncGenerator

aclose(self)

  Raise GeneratorExit inside coroutine.
        
asend(self, value)

  Send a value into the asynchronous generator.
          Return next yielded value or raise StopAsyncIteration.
        
athrow(self, typ, val=None, tb=None)

  Raise an exception in the asynchronous generator.
          Return next yielded value or raise StopAsyncIteration.
        

AsyncIterable

AsyncIterator

Awaitable

ByteString

This unifies bytes and bytearray.

    XXX Should add all their methods.
    
count(self, value)

  S.count(value) -> integer -- return number of occurrences of value
index(self, value, start=0, stop=None)

  S.index(value, [start, [stop]]) -> integer -- return first index of value.
             Raises ValueError if the value is not present.

             Supporting start and stop arguments is optional, but
             recommended.
        

Callable

Collection

Container

Coroutine

close(self)

  Raise GeneratorExit inside coroutine.
        
send(self, value)

  Send a value into the coroutine.
          Return next yielded value or raise StopIteration.
        
throw(self, typ, val=None, tb=None)

  Raise an exception in the coroutine.
          Return next yielded value or raise StopIteration.
        

ellipsis

function

Create a function object.

  code
    a code object
  globals
    the globals dictionary
  name
    a string that overrides the name from the code object
  argdefs
    a tuple that specifies the default argument values
  closure
    a tuple that supplies the bindings for free variables

Generator

close(self)

  Raise GeneratorExit inside generator.
        
send(self, value)

  Send a value into the generator.
          Return next yielded value or raise StopIteration.
        
throw(self, typ, val=None, tb=None)

  Raise an exception in the generator.
          Return next yielded value or raise StopIteration.
        

GenericAlias

Represent a PEP 585 generic type

E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).

Hashable

ItemsView

isdisjoint(self, other)

  Return True if two sets have a null intersection.

Iterable

Iterator

KeysView

isdisjoint(self, other)

  Return True if two sets have a null intersection.

Mapping

A Mapping is a generic container for associating key/value
    pairs.

    This class provides concrete generic implementations of all
    methods except for __getitem__, __iter__, and __len__.
    
get(self, key, default=None)

  D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
items(self)

  D.items() -> a set-like object providing a view on D's items
keys(self)

  D.keys() -> a set-like object providing a view on D's keys
values(self)

  D.values() -> an object providing a view on D's values

MappingView

MutableMapping

A MutableMapping is a generic container for associating
    key/value pairs.

    This class provides concrete generic implementations of all
    methods except for __getitem__, __setitem__, __delitem__,
    __iter__, and __len__.
    
clear(self)

  D.clear() -> None.  Remove all items from D.
get(self, key, default=None)

  D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
items(self)

  D.items() -> a set-like object providing a view on D's items
keys(self)

  D.keys() -> a set-like object providing a view on D's keys
pop(self, key, default=<object object at 0x7f75e3c94190>)

  D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
            If key is not found, d is returned if given, otherwise KeyError is raised.
        
popitem(self)

  D.popitem() -> (k, v), remove and return some (key, value) pair
             as a 2-tuple; but raise KeyError if D is empty.
        
setdefault(self, key, default=None)

  D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
update(self, other=(), /, **kwds)

   D.update([E, ]**F) -> None.  Update D from mapping/iterable E and F.
              If E present and has a .keys() method, does:     for k in E: D[k] = E[k]
              If E present and lacks .keys() method, does:     for (k, v) in E: D[k] = v
              In either case, this is followed by: for k, v in F.items(): D[k] = v
        
values(self)

  D.values() -> an object providing a view on D's values

MutableSequence

All the operations on a read-write sequence.

    Concrete subclasses must provide __new__ or __init__,
    __getitem__, __setitem__, __delitem__, __len__, and insert().
    
append(self, value)

  S.append(value) -- append value to the end of the sequence
clear(self)

  S.clear() -> None -- remove all items from S
count(self, value)

  S.count(value) -> integer -- return number of occurrences of value
extend(self, values)

  S.extend(iterable) -- extend sequence by appending elements from the iterable
index(self, value, start=0, stop=None)

  S.index(value, [start, [stop]]) -> integer -- return first index of value.
             Raises ValueError if the value is not present.

             Supporting start and stop arguments is optional, but
             recommended.
        
insert(self, index, value)

  S.insert(index, value) -- insert value before index
pop(self, index=-1)

  S.pop([index]) -> item -- remove and return item at index (default last).
             Raise IndexError if list is empty or index is out of range.
        
remove(self, value)

  S.remove(value) -- remove first occurrence of value.
             Raise ValueError if the value is not present.
        
reverse(self)

  S.reverse() -- reverse *IN PLACE*

MutableSet

A mutable set is a finite, iterable container.

    This class provides concrete generic implementations of all
    methods except for __contains__, __iter__, __len__,
    add(), and discard().

    To override the comparisons (presumably for speed, as the
    semantics are fixed), all you have to do is redefine __le__ and
    then the other operations will automatically follow suit.
    
add(self, value)

  Add an element.
clear(self)

  This is slow (creates N new iterators!) but effective.
discard(self, value)

  Remove an element.  Do not raise an exception if absent.
isdisjoint(self, other)

  Return True if two sets have a null intersection.
pop(self)

  Return the popped value.  Raise KeyError if empty.
remove(self, value)

  Remove an element. If not a member, raise a KeyError.

Reversible

Sequence

All the operations on a read-only sequence.

    Concrete subclasses must override __new__ or __init__,
    __getitem__, and __len__.
    
count(self, value)

  S.count(value) -> integer -- return number of occurrences of value
index(self, value, start=0, stop=None)

  S.index(value, [start, [stop]]) -> integer -- return first index of value.
             Raises ValueError if the value is not present.

             Supporting start and stop arguments is optional, but
             recommended.
        

Set

A set is a finite, iterable container.

    This class provides concrete generic implementations of all
    methods except for __contains__, __iter__ and __len__.

    To override the comparisons (presumably for speed, as the
    semantics are fixed), redefine __le__ and __ge__,
    then the other operations will automatically follow suit.
    
isdisjoint(self, other)

  Return True if two sets have a null intersection.

Sized

ValuesView

async_generator

aclose(...)

  aclose() -> raise GeneratorExit inside generator.
asend(...)

  asend(v) -> send 'v' in generator.
athrow(...)

  athrow(typ[,val[,tb]]) -> raise exception in generator.
ag_await = <attribute 'ag_await' of 'async_generator' objects>
  object being awaited on, or None
ag_code = <member 'ag_code' of 'async_generator' objects>
ag_frame = <member 'ag_frame' of 'async_generator' objects>
ag_running = <member 'ag_running' of 'async_generator' objects>

bytearray_iterator

bytes_iterator

coroutine

close(...)

  close() -> raise GeneratorExit inside coroutine.
send(...)

  send(arg) -> send 'arg' into coroutine,
  return next iterated value or raise StopIteration.
throw(...)

  throw(value)
  throw(type[,value[,traceback]])

  Raise exception in coroutine, return next iterated value or raise
  StopIteration.
cr_await = <attribute 'cr_await' of 'coroutine' objects>
  object being awaited on, or None
cr_code = <member 'cr_code' of 'coroutine' objects>
cr_frame = <member 'cr_frame' of 'coroutine' objects>
cr_origin = <member 'cr_origin' of 'coroutine' objects>
cr_running = <attribute 'cr_running' of 'coroutine' objects>

dict_itemiterator

dict_items

isdisjoint(...)

  Return True if the view and the given iterable have a null intersection.
mapping = <attribute 'mapping' of 'dict_items' objects>
  dictionary that this view refers to

dict_keyiterator

dict_keys

isdisjoint(...)

  Return True if the view and the given iterable have a null intersection.
mapping = <attribute 'mapping' of 'dict_keys' objects>
  dictionary that this view refers to

dict_valueiterator

dict_values

mapping = <attribute 'mapping' of 'dict_values' objects>
  dictionary that this view refers to

generator

close(...)

  close() -> raise GeneratorExit inside generator.
send(...)

  send(arg) -> send 'arg' into generator,
  return next yielded value or raise StopIteration.
throw(...)

  throw(value)
  throw(type[,value[,tb]])

  Raise exception in generator, return next yielded value or raise
  StopIteration.
gi_code = <member 'gi_code' of 'generator' objects>
gi_frame = <member 'gi_frame' of 'generator' objects>
gi_running = <attribute 'gi_running' of 'generator' objects>
gi_yieldfrom = <attribute 'gi_yieldfrom' of 'generator' objects>
  object being iterated by yield from, or None

list_iterator

list_reverseiterator

longrange_iterator

mappingproxy

copy(...)

  D.copy() -> a shallow copy of D
get(...)

  D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
items(...)

  D.items() -> a set-like object providing a view on D's items
keys(...)

  D.keys() -> a set-like object providing a view on D's keys
values(...)

  D.values() -> an object providing a view on D's values

range_iterator

set_iterator

str_iterator

tuple_iterator

zip

zip(*iterables, strict=False) --> Yield tuples until an input is exhausted.

   >>> list(zip('abcdefg', range(3), range(4)))
   [('a', 0, 0), ('b', 1, 1), ('c', 2, 2)]

The zip object yields n-length tuples, where n is the number of iterables
passed as positional arguments to zip().  The i-th element in every tuple
comes from the i-th iterable argument to zip().  This continues until the
shortest argument is exhausted.

If strict is true and one of the arguments is exhausted before the others,
raise a ValueError.

Functions

abstractmethod

abstractmethod(funcobj)

  A decorator indicating abstract methods.

      Requires that the metaclass is ABCMeta or derived from it.  A
      class that has a metaclass derived from ABCMeta cannot be
      instantiated unless all of its abstract methods are overridden.
      The abstract methods can be called using any of the normal
      'super' call mechanisms.  abstractmethod() may be used to declare
      abstract methods for properties and descriptors.

      Usage:

          class C(metaclass=ABCMeta):
              @abstractmethod
              def my_abstract_method(self, ...):
                  ...
    

Modules

sys