[Python-bugs-list] [ python-Bugs-560438 ] foo() doesn't use __getattribute__
noreply@sourceforge.net
noreply@sourceforge.net
Sat, 25 May 2002 01:59:51 -0700
Bugs item #560438, was opened at 2002-05-25 08:59
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=560438&group_id=5470
Category: Type/class unification
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Steve Alexander (stevea_zope)
Assigned to: Nobody/Anonymous (nobody)
Summary: foo() doesn't use __getattribute__
Initial Comment:
In the Python 2.2 release notes, it says::
- For new-style classes, what was previously called
__getattr__ is now
called __getattribute__. This method, if defined, is
called for
*every* attribute access.
However, if I define a callable class that also defines
a __getattribute__ method, the __getattribute__ method
is not used when I say instance().
class Foo(object):
def __getattribute__(self, name):
print "__getattribute__ with name =",name
if name=="__call__":
return lambda:1
object.__getattribute__(self, name)
def __call__(self):
print "__call__ method called"
f = Foo()
f.__call__()
f()
$ python /tmp/test.py
__getattribute__ with name = __call__
__call__ method called
I would expect the second line of output to be the same
as the first.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=560438&group_id=5470