Re: Trouble with generator as method

2006-03-22 Thread Peter Cole
Peter Otten wrote: > Peter Cole wrote: > >> I'm having difficulty understanding why this doesn't work: > >> import sys, new, inspect >> >> class T: >> def foo(self): >> yield 1 >> yield 2 >> yield 3 >> >> >> t = T() > > im = new.instancemethod(T.foo, t, T) > >> prin

Re: Trouble with generator as method

2006-03-22 Thread Peter Otten
Peter Cole wrote: > I'm having difficulty understanding why this doesn't work: > import sys, new, inspect > > class T: >  def foo(self): > yield 1 > yield 2 > yield 3 > > > t = T() im = new.instancemethod(T.foo, t, T) > print t.foo > print im # prints # > # > >F

Trouble with generator as method

2006-03-22 Thread Peter Cole
I'm having difficulty understanding why this doesn't work: import sys, new, inspect class T: def foo(self): yield 1 yield 2 yield 3 t = T() ic = t.__class__ for key in ic.__dict__.keys(): if inspect.isfunction(ic.__dict__[key]): im = new.instancemetho