Last active
May 24, 2019 05:09
-
-
Save I159/cf3dad05a5d5b92ba0ba904e4317d78e 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
import abc | |
# Entities level | |
class Entity(metaclass=abc.ABCMeta): | |
@abc.abstractmethod | |
def _lower_level_meth(self): | |
raise NotImplementedError | |
@property | |
def entity_prop(self): | |
return self._lower_level_meth() | |
# Adapters level | |
class ImplementedEntity(Entity): | |
__private = 'private attribute value' | |
def __init__(self, pub_attr): | |
self.pub_attr = pub_attr | |
def _lower_level_meth(self): | |
print('{}\n{}'.format(self.pub_attr, self.__private)) | |
# Infrastructure level | |
if __name__ == '__main__': | |
ENTITY = ImplementedEntity('public attribute value') | |
ENTITY.entity_prop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment