2.2: __call__ method via __getattr__ not working
Drew Csillag
drew_csillag at geocities.com
Tue Aug 14 19:54:22 EDT 2001
I don't know if this is a known bug in the current CVS version of 2.2
but the following code breaks.
class bar(object):
def __call__(self, args):
print args
b = bar()
b(1) #works ok here
class foo(object):
def _call_(self, args):
print args
def __getattr__(self, attr):
if attr == '__call__':
return self._call_
raise AttributeError, attr
f = foo()
f(1) #dies here
It gives the following traceback:
Traceback (most recent call last):
File "tt.py", line 17, in ?
f(1)
TypeError: object is not callable: <foo object at 0x8148208>
Thanks,
Drew
--
print(lambda(m,d,y):['Sun','Mon','Tues','Wed','Thurs','Fri','Satur'][(
lambda(m,d,y):(23*m/9+d+4+y/4-y/100+y/400)%7)(m<3and(m,d+y,y-1)or(m,
d+(y-2),y))])(map(int,raw_input('mm/dd/yyyy>').split('/')))+'day'
More information about the Python-list
mailing list