[IronPython] Is there a better way?

Slide slide.o.mix at gmail.com
Fri Mar 4 07:46:40 PST 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 Users mailing list