Re: Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Michele Simionato" <[EMAIL PROTECTED]> wrote: > Duncan Booth wrote: > > Ron Garret <[EMAIL PROTECTED]> wrote: > > > > > I want to say: > > > > > > trace(c1.m1) > > > > > > and have c1.m1 be replaced with a wrapper that prints debugging info > > > before actually c

Re: Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Kent Johnson <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > The reason I want to do this is that I want to implement a trace > > facility that traces only specific class methods. I want to say: > > > > trace(c1.m1) > > > > and have c1.m1 be replaced with a

Re: Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Kent Johnson
Ron Garret wrote: > The reason I want to do this is that I want to implement a trace > facility that traces only specific class methods. I want to say: > > trace(c1.m1) > > and have c1.m1 be replaced with a wrapper that prints debugging info > before actually calling the old value of m1. The

Re: Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Kent Johnson
Ron Garret wrote: > The reason I want to do this is that I want to implement a trace > facility that traces only specific class methods. I want to say: > > trace(c1.m1) > > and have c1.m1 be replaced with a wrapper that prints debugging info > before actually calling the old value of m1. The

Re: Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Michele Simionato
Duncan Booth wrote: > Ron Garret <[EMAIL PROTECTED]> wrote: > > > I want to say: > > > > trace(c1.m1) > > > > and have c1.m1 be replaced with a wrapper that prints debugging info > > before actually calling the old value of m1. The reason I want that > > to be an instance of a callable class inste

Re: Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Duncan Booth
Ron Garret <[EMAIL PROTECTED]> wrote: > I want to say: > > trace(c1.m1) > > and have c1.m1 be replaced with a wrapper that prints debugging info > before actually calling the old value of m1. The reason I want that > to be an instance of a callable class instead of a function is that I > need

Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Ron Garret
If I do this: def f(self): print self class c1: pass setattr(c1, 'm1', f) Then f is automagically transmogrified into the appropriate sort of method depending on how it is used: >>> c1.m1 >>> c1().m1 > >>> c1().m1() <__main__.c1 instance at 0x51ec60> Note that m1 gets passed a self argument