Maybe I just don't know the right special function, but what I am wanting to
do is write something akin to a __getattr__ function so that when you try to
call an object method that doesn't exist, it get's intercepted *along with
it's argument*, in the same manner as __getattr__ intercepts attributes
references for attributes that don't exist.
This doesn't quite work:
[color=blue][color=green][color=darkred]
>>> class Foo:[/color][/color][/color]
.... def __getattr__(sel f, att_name, *args):
.... print "%s%s" % (att_name, str(tuple(*args )))
....[color=blue][color=green][color=darkred]
>>> f = Foo()
>>> f.bar[/color][/color][/color]
bar()[color=blue][color=green][color=darkred]
>>> f.bar(1,2,3)[/color][/color][/color]
bar()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'NoneType' object is not callable[color=blue][color=green][color=darkred]
>>> f.bar()[/color][/color][/color]
bar()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'NoneType' object is not callable
Is there some other special function like __getattr__ that does what I want?
Thanks,
-ej
Comment