view Methods @ 58:a7a67be0697c

created
author 127.0.0.1
date Sat, 29 Jun 2013 12:53:58 +0200
parents e25314562515
children
line wrap: on
line source

{{{#!python
class UnboundMethod(object):
    def __init__(self, func):
        self.__func__ = func

    def __call__(self, *args, **kwargs):
        return self.__func__(*args, **kwargs)

    def __get__(self, instance, owner):
        return BoundMethod(instance, self.__func__)

class BoundMethod(object):
    def __init__(self, instance, func):
        self.__self__, self.__func__ = instance, func

    def __call__(self, *args, **kwargs):
        return self.__func__(self.__self__, *args, **kwargs)
}}}