Created
November 1, 2021 17:05
-
-
Save IgorZyktin/9a5a6589e78335c9e21bea81d176bbdc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from abc import ABC, abstractmethod | |
class A(ABC): | |
@property | |
@abstractmethod | |
def attr(self) -> str: | |
... | |
class B: | |
attr: str | |
class C(A): | |
def __init__(self): | |
self.attr = '25' | |
a = A() # TypeError: Can't instantiate abstract class A with abstract methods attr | |
b = B() | |
b.attr # AttributeError: 'B' object has no attribute 'attr' | |
c = C() # AttributeError: 'B' object has no attribute 'attr' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment