On Thu, Jul 28, 2011 at 5:08 AM, Peter Otten <[email protected]> wrote:

> Pete O'Connell wrote:
>
> > Hi I was wondering if there is a way to disable a function.
>
>
You could use this decorator:
class Disabler(object):
    def __init__(self, old_function):
        self.__old = old_function
        self.enabled=True
    def __call__(self, *arg, **kwd):
        if enabled: return self.__old(*arg, **kwd)
    def enable(self): self.enabled = True
    def disable(self): self.enabled=False


> _______________________________________________
> Tutor maillist  -  [email protected]
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to