_py_abc
| Use Case | Command | Description |
|---|---|---|
| Create an Abstract Base Class | class MyABC(metaclass=ABCMeta): | Define a new ABC using ABCMeta as metaclass |
| Register a virtual subclass | MyABC.register(SomeClass) | Make SomeClass a virtual subclass of MyABC |
| Check instance (including virtual) | isinstance(obj, MyABC) | Override __instancecheck__ for virtual subclasses |
| Check subclass (including virtual) | issubclass(SomeClass, MyABC) | Override __subclasscheck__ for virtual subclasses |
| Get ABC cache token | get_cache_token() | Opaque token that changes on every register() call |
https://docs.python.org/3.10/library/_py_abc.html
The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.
builtins.type(builtins.object) → ABCMeta
ABCMeta(name, bases, namespace, /, **kwargs)
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()).
ABCMeta
builtins.type
builtins.object
__instancecheck__(cls, instance) — Override for isinstance(instance, cls).__subclasscheck__(cls, subclass) — Override for issubclass(subclass, cls).register(cls, subclass) — Register a virtual subclass of an ABC. Returns the subclass, to allow usage as a class decorator.__new__(mcls, name, bases, namespace, /, **kwargs) — Create and return a new object. See help(type) for accurate signature.__annotations__ = {}__call__(self, /, *args, **kwargs) — Call self as a function.__delattr__(self, name, /) — Implement delattr(self, name).__dir__(self, /) — Specialized __dir__ implementation for types.__getattribute__(self, name, /) — Return getattr(self, name).__init__(self, /, *args, **kwargs) — Initialize self. See help(type(self)) for accurate signature.__or__(self, value, /) — Return self|value.__repr__(self, /) — Return repr(self).__ror__(self, value, /) — Return value|self.__setattr__(self, name, value, /) — Implement setattr(self, name, value).__sizeof__(self, /) — Return memory consumption of the type object.__subclasses__(self, /) — Return a list of immediate subclasses.mro(self, /) — Return a type's method resolution order.__prepare__(...) from builtins.type — __prepare__() -> dict used to create the namespace for the class statement__abstractmethods____dict____text_signature____base__ = <class 'type'> — type(object) -> the object's type; type(name, bases, dict, **kwds) -> a new type__bases__ = (<class 'type'>,)__basicsize__ = 888__dictoffset__ = 264__flags__ = 2148029952__itemsize__ = 40__mro__ = (<class '_py_abc.ABCMeta'>, <class 'type'>, <class 'object'>...)__weakrefoffset__ = 368Returns 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.
/usr/lib/python3.10/_py_abc.py
Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 12:14 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format