Why doesnt __getattr__ with decorator dont call __get_method in decorator
tbrkic at yahoo.com
Wed Mar 28 17:09:40 CEST 2007
On Mar 28, 4:47 pm, a... at mac.com (Alex Martelli) wrote:
> glomde <tbr... at yahoo.com> wrote:
> > Hi,
> > I tried to write a decorator for that should be for methods but for
> > some reasons
> > it doens seem to work when you try to do it on the __getattr__ method
> > in a class.
> > Could anybody give some hints why this is?
> > a.test # This doesnt call the __get__ !!!
> > Output
> > __get__ <__main__.MyClass1 object at 0x4012baac>
> > hello1
> > Traceback (most recent call last):
> > File "/home/tonib/test.py", line 27, in ?
> > a.test
> > File "/home/tonib/test.py", line 12, in __call__
> > return self.func(self.instance, *args, **kwds)
> > AttributeError: 'decoratorTest' object has no attribute 'instance'
> What Python release are you using? With Python 2.5, your code gives me
> >>> a.test
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "a.py", line 11, in __call__
> return self.func(self.instance, *args, **kwds)
> TypeError: __getattr__() takes exactly 2 arguments (3 given)
> so there would seem to be some "mis-alignment" wrt the problems you
I was using 2.4 but I downloaded and installed ActivePython22.214.171.124 and
for I get the same message as in my original email.
What python version do you use more exactly?
More information about the Python-list