new.instancemethod __iter__

Martin Drautzburg Martin.Drautzburg at web.de
Sun Feb 7 04:54:16 EST 2010


Christian Heimes wrote:


> If you *really* need to overwrite __iter__ on your instance rather
> than defining it on your class, you need to proxy the method call:
> 
> class MyObject(object):
>    def __iter__(self):
>       return self.myiter()
> 
> obj = MyObject()
> obj.myiter = myiter
> 
> That should do the trick.

Thanks a lot, that works.



More information about the Python-list mailing list