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 | |
class Renderer(metaclass=ABCMeta): | |
def __init__(self, entity): | |
self._entity = entity | |
self._render_entity = self._locate_renderer() | |
def _locate_renderer(self): | |
for cls in self.__class__.mro(): |
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 __future__ import teleport | |
from abc import ABCMeta | |
class Renderer(metaclass=ABCMeta): | |
def __init__(self, entity): | |
self._entity = entity | |
@teleport |
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 Renderer(metaclass=ABCMeta): | |
def __init__(self, entity): | |
self._entity = entity | |
@abstractmethod | |
def __call__(self): | |
raise TypeError('Not recognized') |
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 Renderer(metaclass=ABCMeta): | |
def __init__(self, entity): | |
self._entity = entity | |
@abstractmethod | |
def __call__(self): | |
raise NotImplementedError |
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
class Renderer: | |
def __init__(self, entity): | |
self._entity = entity | |
class IntRenderer(Renderer): | |
__type = int | |
def __render_entity(self): | |
return 'INTEGER {}'.format(self._entity) |
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
def initial(): | |
do_some_initialization() | |
def first_branch(data): | |
pass | |
def default_branch(data): | |
pass | |
def should_execute_first(data): |