20170620 계량 화: BT 역 추적 창고

재 검 사 를 하 는 창고 가 매우 편리 하 다 는 것 을 발견 하고 기록 하 세 요.
http://pmorissette.github.io/bt/index.html#what-is-bt
그 중에서 도 어 려 운 점 은 알 고 스 같은...
class Algo(object):
"""
Algos are used to modularize strategy logic so that strategy logic becomes
modular, composable, more testable and less error prone. Basically, the
Algo should follow the unix philosophy - do one thing well.

In practice, algos are simply a function that receives one argument, the
Strategy (refered to as target) and are expected to return a bool.

When some state preservation is necessary between calls, the Algo
object can be used (this object). The __call___ method should be
implemented and logic defined therein to mimic a function call. A
simple function may also be used if no state preservation is neceesary.

Args:
    * name (str): Algo name

"""

def __init__(self, name=None):
    self._name = name

@property
def name(self):
    """
    Algo name.
    """
    if self._name is None:
        self._name = self.__class__.__name__
    return self._name

def __call__(self, target):
    raise NotImplementedError("%s not implemented!" % self.name)

좋은 웹페이지 즐겨찾기