💾 Archived View for tris.fyi › pydoc › _collections_abc captured on 2022-04-28 at 17:29:08. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-03-01)
-=-=-=-=-=-=-
Abstract Base Classes (ABCs) for collections, according to PEP 3119. Unit tests are in test_collections.
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.
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.
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.
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.
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
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.
Represent a PEP 585 generic type E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
isdisjoint(self, other) Return True if two sets have a null intersection.
isdisjoint(self, other) Return True if two sets have a null intersection.
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
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 0x7ff3609c6170>) 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
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*
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.
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.
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.
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>
close(...) close() -> raise GeneratorExit inside coroutine.
send(...) send(arg) -> send 'arg' into coroutine, return next iterated value or raise StopIteration.
throw(...) throw(typ[,val[,tb]]) -> 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 = <member 'cr_running' of 'coroutine' objects>
isdisjoint(...) Return True if the view and the given iterable have a null intersection.
isdisjoint(...) Return True if the view and the given iterable have a null intersection.
close(...) close() -> raise GeneratorExit inside generator.
send(...) send(arg) -> send 'arg' into generator, return next yielded value or raise StopIteration.
throw(...) throw(typ[,val[,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 = <member 'gi_running' of 'generator' objects>
gi_yieldfrom = <attribute 'gi_yieldfrom' of 'generator' objects> object being iterated by yield from, or None
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() -> list of D's (key, value) pairs, as 2-tuples
keys(...) D.keys() -> list of D's keys
values(...) D.values() -> list of D's values
zip(*iterables) --> A zip object yielding 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.
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, ...): ...