💾 Archived View for tris.fyi › pydoc › abc captured on 2022-03-01 at 15:52:46. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-01-08)

➡️ Next capture (2022-07-16)

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

Back to module index

Go to module by name

abc

Abstract Base Classes (ABCs) according to PEP 3119.

Classes

ABC

Helper class that provides a standard way to create an ABC using
    inheritance.
    

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.
            

abstractclassmethod

A decorator indicating abstract classmethods.

    Deprecated, use 'classmethod' with 'abstractmethod' instead:

        class C(ABC):
            @classmethod
            @abstractmethod
            def my_abstract_classmethod(cls, ...):
                ...

    

abstractproperty

A decorator indicating abstract properties.

    Deprecated, use 'property' with 'abstractmethod' instead:

        class C(ABC):
            @property
            @abstractmethod
            def my_abstract_property(self):
                ...

    
deleter(...)

  Descriptor to change the deleter on a property.
getter(...)

  Descriptor to change the getter on a property.
setter(...)

  Descriptor to change the setter on a property.
fdel = <member 'fdel' of 'property' objects>
fget = <member 'fget' of 'property' objects>
fset = <member 'fset' of 'property' objects>

abstractstaticmethod

A decorator indicating abstract staticmethods.

    Deprecated, use 'staticmethod' with 'abstractmethod' instead:

        class C(ABC):
            @staticmethod
            @abstractmethod
            def my_abstract_staticmethod(...):
                ...

    

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, ...):
                  ...
    

get_cache_token

get_cache_token()

  Returns the current ABC cache token.

  The token is an opaque object (supporting equality testing) identifying the
  current version of the ABC cache for virtual subclasses. The token changes
  with every call to register() on any ABC.