On this page
abc.abstractmethod
Prev: abc.abstractclassmethod | Up: abc | Next: abc.abstractproperty
Rel: abc.ABC, abc.ABCMeta, abc.abstractclassmethod, abc.abstractproperty
Ref: docs.python.org — abc.abstractmethod
Tags: #public #python3 #stdlib #abc
Import
import abc
from abc import abstractmethod
Signature & Overview
abc.abstractmethod(funcobj)
A decorator indicating abstract methods.
Usage
from abc import ABC, abstractmethod
class Repo(ABC):
@abstractmethod
def get(self, key: str) -> str: ...
try:
Repo()
except TypeError:
assert True
Gotchas
- Must be the innermost decorator: Stack
@property,@classmethod, or@staticmethodabove@abstractmethod. - No effect without
ABC/ABCMeta: A plain class withoutABCignores@abstractmethod.
REPL Inspect
from abc import abstractmethod
help(abstractmethod)
Linked from
- tuts/python3/stdlib_module/abc
- tuts/python3/stdlib_module/abc/ABC
- tuts/python3/stdlib_module/abc/ABCMeta
- tuts/python3/stdlib_module/abc/abstractclassmethod
- tuts/python3/stdlib_module/abc/abstractproperty
- tuts/python3/stdlib_module/abc/abstractstaticmethod
- tuts/python3/stdlib_module/abc/get_cache_token
- tuts/python3/stdlib_module/abc/update_abstractmethods
Related notes
- tuts/python3/stdlib_module/abc/ABC Linked here; links to this page; shared tags: #abc, #stdlib
- tuts/python3/stdlib_module/abc/ABCMeta Linked here; links to this page; shared tags: #abc, #stdlib
- tuts/python3/stdlib_module/abc/abstractclassmethod Linked here; links to this page; shared tags: #abc, #stdlib
- tuts/python3/stdlib_module/abc/abstractproperty Linked here; links to this page; shared tags: #abc, #stdlib
- tuts/python3/stdlib_module/abc/abstractstaticmethod links to this page; shared tags: #abc, #stdlib
- tuts/python3/stdlib_module/abc/get_cache_token links to this page; shared tags: #abc, #stdlib
- tuts/python3/stdlib_module/abc/update_abstractmethods links to this page; shared tags: #abc, #stdlib
- tuts/python3/stdlib_module/abc links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib