[IronPython] Is there a better way?

Slide slide.o.mix at gmail.com
Fri Mar 4 16:46:40 CET 2011

Is there a better way to get an enumerator from an object passed in to
a C# implemented module?

IEnumerator e = null;
if (sequence is IEnumerator)
    e = sequence as IEnumerator;
else if (sequence is IEnumerable)
    e = ((IEnumerable)sequence).GetEnumerator();

if (e == null)
    throw PythonOps.TypeError("writerows() argument must be iterable");


More information about the Ironpython-users mailing list