[IronPython] Writing a Python iterator in C#?

Dino Viehland dinov at microsoft.com
Sat May 1 00:34:37 CEST 2010


Jeff wrote:
> On Fri, Apr 30, 2010 at 4:19 PM, Dino Viehland <dinov at microsoft.com> wrote:
> > That's definitely a bug.  We usually check for the interfaces first and
> > we have a code path that's assuming we have a user-defined object when
> > we're not an enumerable/enumerator but we have __iter__.  It's easy
> > enough to fix we're just trying to generate optimal code for getting
> > the Python type of an object.
> 
> I'll file an issue.
> 
> > Is there a reason you can't implement IEnumerator/IEnumerable?
> 
> I'd like to reuse my existing next() method to do that (it's really
> complicated), but it requires a CodeContext - which I can't pass to
> GetEnumerator(), AFAIK.

Oh, bummer...  Can you have the instance hold onto the code context when
it gets created?  That might be a reasonable workaround for the time 
being.





More information about the Ironpython-users mailing list