[Tutor] Intercepting methods calls
andreas at kostyrka.org
Thu Jun 5 12:52:55 CEST 2008
On Thursday 05 June 2008 12:31:56 you wrote:
> On Jun 5, 2008, at 6:06 PM, Andreas Kostyrka wrote:
> > well, don't return a string :-P
> > class CallableString(str):
> > def __call__(self, *args, **kw):
> > return self
> > And now instead of return '', write return CallableString('')
> Whoa, trippy.
> That certainly works, but it's a workaround to the original question –
> is there actually any way to 'detect' an attribute/method call?
No, because there are no "method calls" in Python.
locate obj in locals/globals.
locate method on obj
call the found thing.
obj => obj.method => obj.method()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part.
More information about the Tutor