On this page
  1. abc.update_abstractmethods
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

abc.update_abstractmethods

Prev: abc.get_cache_token | Up: abc
Rel: abc.ABC, abc.ABCMeta, abc.abstractclassmethod, abc.abstractmethod
Ref: docs.python.org — abc.update_abstractmethods
Tags: #public #python3 #stdlib #abc


Import

import abc
from abc import update_abstractmethods

Signature & Overview

abc.update_abstractmethods(cls)

Recalculate the set of abstract methods of an abstract class.

Usage

from abc import ABC, abstractmethod, update_abstractmethods

def fill_area(cls):
    cls.area = lambda self: 1.0
    return update_abstractmethods(cls)

class Base(ABC):
    @abstractmethod
    def area(self) -> float: ...

@fill_area
class Unit(Base):
    pass

assert Unit().area() == 1.0

Gotchas

REPL Inspect

from abc import update_abstractmethods
help(update_abstractmethods)

Linked from

Related notes