[Pyrex] __iter__ and yield

Mike Wyatt mikejohnwyatt at gmail.com
Mon Sep 20 05:22:40 CEST 2010


I figured it out:

    def __iter__( cVector2 self ):
        return iter( (self.x, self.y) )


On Sun, Sep 19, 2010 at 10:17 PM, Mike Wyatt <mikejohnwyatt at gmail.com>wrote:

> I want to write a simple iterator for my vector class, but this code isn't
> compiling:
>
>     def __iter__( cVector2 self ):
>         yield self.x      # line 247
>         yield self.y
>
> I get this error:
>
> pyrexc src/cVector2.pyx --> src/cVector2.c
> C:\Development\MikeLib\src/cVector2.pyx:247:8: Syntax error in simple
> statement list
>
> Thoughts on how to make this work?  I'm using Pyrex 0.9.9 with Python 2.6.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.copyleft.no/pipermail/pyrex/attachments/20100919/e2714366/attachment.html>


More information about the Pyrex mailing list