On Fri, 28 Jan 2005 11:59:50 -0500, Hans Nowak <[EMAIL PROTECTED]> wrote: > Bill Mill wrote: > > > On Fri, 28 Jan 2005 11:09:16 -0500, Hans Nowak <[EMAIL PROTECTED]> wrote: > > <snip> > > > >>To add m as a new method to the *class*, do this: > >> > >> >>> class test: > >>... def __init__(self, method): > >>... self.__class__.method = method > >>... self.method() > >>... > >> >>> def m(self): print self > >>... > >> >>> test(m) > >><__main__.test instance at 0x0192ED78> > >><__main__.test instance at 0x0192ED78> > > > > > > When I run it, I only get one call to m, which is how I would expect > > python to work; I assume the double printing here is a typo? > > Actually, no. I'm using the interactive interpreter, so doing test(m) > results in two lines: the first one is printed by m, the second one is > the __repr__ of the test instance that was created, displayed by the > interpreter. Compare: > > >>> x = test(m) > <__main__.test instance at 0x0192ED78> > >>> x > <__main__.test instance at 0x0192ED78> >
d'oh; that's how I ran it. Thanks a lot. > -- > Hans Nowak > http://zephyrfalcon.org/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list