Created
February 12, 2017 21:19
-
-
Save dbader/04d1d42e71562f946163286f37699dd7 to your computer and use it in GitHub Desktop.
This file contains 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 ABCMeta, abstractmethod | |
class Base(metaclass=ABCMeta): | |
def __init__(self): | |
self.my_attrib = 42 | |
@abstractmethod | |
def foo(self): | |
pass | |
@property | |
@abstractmethod | |
def my_prop(self): | |
pass | |
class Concrete(Base): | |
def __init__(self): | |
super().__init__() | |
self.other_attrib = 999 | |
def foo(self): | |
pass | |
@property | |
def my_prop(self): | |
return self.other_attrib + 1 | |
>>> c = Concrete() | |
>>> c.my_attrib | |
42 | |
>>> c.other_attrib | |
999 | |
>>> c.my_prop | |
1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment