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
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
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
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
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
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
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