Re: Monkeypatching an object to become callable

2009-08-13 Thread Gabriel Genellina
En Tue, 11 Aug 2009 20:21:16 -0300, Nikolaus Rath escribió: Bruno Desthuilliers writes: 7stud a écrit : (snip) class Wrapper(object): def __init__(self, obj, func): self.obj = obj self.func = func def __call__(self, *args): return self.func(*args) def

Re: Monkeypatching an object to become callable

2009-08-11 Thread Nikolaus Rath
Bruno Desthuilliers writes: > 7stud a écrit : > (snip) >> class Wrapper(object): >> def __init__(self, obj, func): >> self.obj = obj >> self.func = func >> >> def __call__(self, *args): >> return self.func(*args) >> >> def __getattr__(self, name): >> ret

Re: Monkeypatching an object to become callable

2009-08-10 Thread Bruno Desthuilliers
7stud a écrit : (snip) class Wrapper(object): def __init__(self, obj, func): self.obj = obj self.func = func def __call__(self, *args): return self.func(*args) def __getattr__(self, name): return object.__getattribute__(self.obj, name) This should b

Re: Monkeypatching an object to become callable

2009-08-09 Thread 7stud
On Aug 9, 1:02 pm, Nikolaus Rath wrote: > Hi, > > I want to monkeypatch an object so that it becomes callable, although > originally it is not meant to be. (Yes, I think I do have a good reason > to do so). > > But simply adding a __call__ attribute to the object apparently isn't > enough, and I d

Re: Monkeypatching an object to become callable

2009-08-09 Thread Carl Banks
On Aug 9, 12:02 pm, Nikolaus Rath wrote: > Hi, > > I want to monkeypatch an object so that it becomes callable, although > originally it is not meant to be. (Yes, I think I do have a good reason > to do so). > > But simply adding a __call__ attribute to the object apparently isn't > enough, and I

Re: Monkeypatching an object to become callable

2009-08-09 Thread Diez B. Roggisch
Nikolaus Rath schrieb: Hi, I want to monkeypatch an object so that it becomes callable, although originally it is not meant to be. (Yes, I think I do have a good reason to do so). But simply adding a __call__ attribute to the object apparently isn't enough, and I do not want to touch the class

Monkeypatching an object to become callable

2009-08-09 Thread Nikolaus Rath
Hi, I want to monkeypatch an object so that it becomes callable, although originally it is not meant to be. (Yes, I think I do have a good reason to do so). But simply adding a __call__ attribute to the object apparently isn't enough, and I do not want to touch the class object (since it would mo