Properties, Methods, Events

John Flynn transpicio at yahoo.com.au
Wed May 9 22:58:27 EDT 2001


"Fredrik Lundh" <fredrik at pythonware.com> wrote in message
news:BdVJ6.864$Yu6.223845 at newsc.telia.net...
> John Flynn wrote:
> > > Do you know of any way to trap an ordinary method call? Eg. if Time-
> > > Bomb has a method 'tick', can we find a way to know automatically when
> > > it is called?
> >
> > Ahem... On second thoughts, this goes down as the dopiest and most
> > meaningless question in history.
>
> why?  assuming that you meant "... when it is called, without modifying
> the method", it's a rather interesting question.

Yep, that is what I meant the first time, and it _was_ a reasonable question
after all. An hour or so later I was nearly asleep, and I lost sight of what
I was trying to do. "You want to know when a method is called? Just do
something inside the method, you dope!". (Which _is_ the best way 99% of the
time, but not what I wanted here).

> (hint: let __getattr__ return a proxy object if the member is callable,
and
> let that object call the original method from its __call__ method)

Thanks /F (and Alex). I'll play around with this. I really dig this idea of
a language that's not just high level but almost completely transparent if
you know what you're doing. (Not that I do yet).






More information about the Python-list mailing list