Skip to content

Instantly share code, notes, and snippets.

@I159
Last active May 24, 2019 05:09
Show Gist options
  • Save I159/cf3dad05a5d5b92ba0ba904e4317d78e to your computer and use it in GitHub Desktop.
Save I159/cf3dad05a5d5b92ba0ba904e4317d78e to your computer and use it in GitHub Desktop.
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