snipy/basic.py
def patchmethod(*cls, **kwargs):
    """
    클래스 멤버 패치 @patchmethod(Cls1, ..., [name='membername'])
    ex)
    class A(object):
        def __init__(self, data):
            self.data = data

    @patchmethod(A)
    def sample(self):
        ''' haha docstrings '''
        print self.data

    @patchmethod(A, name='membermethod)
    def sample(self):
        ''' haha docstrings '''
        print self.data

    a = A()
    a.sample()

    """

    def _patch(fun):
        m = kwargs.pop('name', None) or fun.__name__
        for c in cls:
            setattr(c, m, fun)
            # c.__dict__[m].__doc__ = fun.__doc__

    def wrap(fun):
        _patch(fun)
        return fun

    return wrap
def patchmethod(*cls, **kwargs):
    """
    클래스 멤버 패치 @patchmethod(Cls1, ..., [name='membername'])
    ex)
    class A(object):
        def __init__(self, data):
            self.data = data

    @patchmethod(A)
    def sample(self):
        ''' haha docstrings '''
        print self.data

    @patchmethod(A, name='membermethod)
    def sample(self):
        ''' haha docstrings '''
        print self.data

    a = A()
    a.sample()

    """

    def _patch(fun):
        m = kwargs.pop('name', None) or fun.__name__
        for c in cls:
            setattr(c, m, fun)
            # c.__dict__[m].__doc__ = fun.__doc__

    def wrap(fun):
        _patch(fun)
        return fun

    return wrap
def patchmethod ( * cls , * * kwargs ) : def _patch ( fun ) : m = kwargs . pop ( 'name' , None ) or fun . __name__ for c in cls : setattr ( c , m , fun ) # c.__dict__[m].__doc__ = fun.__doc__ def wrap ( fun ) : _patch ( fun ) return fun return wrap
클래스 멤버 패치 @patchmethod(Cls1, ..., [name='membername'])
    ex)
    class A(object):
        def __init__(self, data):
            self.data = data

    @patchmethod(A)
    def sample(self):
        ''' haha docstrings '''
        print self.data

    @patchmethod(A, name='membermethod)
    def sample(self):
        ''' haha docstrings '''
        print self.data

    a = A()
    a.sample()
클래스 멤버 패치 @patchmethod ( Cls1 ... [ name = membername ] ) ex ) class A ( object ) : def __init__ ( self data ) : self . data = data