Re: Generic proxy (that proxies methods like __iter__)

2010-01-28 Thread D HANNEY
On Jan 28, 1:31 pm, D HANNEY wrote: > > Your solution works if I change "type(obj)" to say "obj.__class__". > If I don't make this change Python complains "TypeError: Error when > calling the metaclass bases type 'instance' is not an acceptable base > type". > So, I've got something that works but

Re: Generic proxy (that proxies methods like __iter__)

2010-01-28 Thread D HANNEY
On Jan 27, 3:07 pm, Arnaud Delobelle wrote: > On 27 Jan, 14:41, D HANNEY wrote: > [...] > > See [1] for an explanation.  Here is an idea: you could get round that > by generating a class on the fly, if you don't mind changing the class > of the object (untested): > > def noguardproxy(obj): >    

Re: Generic proxy (that proxies methods like __iter__)

2010-01-27 Thread Arnaud Delobelle
On 27 Jan, 14:41, D HANNEY wrote: [...] > >>> class NoGuardProxy(object): > > ... def __init__(self, t): > ... self.t = t > ... def __enter__(self): > ... return self > ... def __exit__(self, type, value, traceback): > ... ret