So simple! Casting to IEnumerable worked great! Maybe I should have mentioned that I'm relatively new to C#, too. I didn't realize you could cast to an interface, though now that I think about it, it makes perfect sense.
Thank you, Jeff. -----Original Message----- From: users-boun...@lists.ironpython.com [mailto:users-boun...@lists.ironpython.com] On Behalf Of Jeff Hardy Sent: Monday, October 11, 2010 12:10 PM To: Discussion of IronPython Subject: Re: [IronPython] Return value from Execute() On Mon, Oct 11, 2010 at 11:40 AM, Mark Senko <mse...@completegenomics.com> wrote: > But I've had an impossible time trying to figure out how to iterate over an > IronPython.Runtime.List as returned by a command such as dir() since it > seems to not be enumerable. > > Typecasting this object doesn't to an array or a List<> doesn't seem to > work. Have you tried casting to IEnumerable? That has always* worked for me. var _pythonRes = source.Execute(_pscope); if(_pythonRes is IEnumerable) { ... } Or, in C# 4, you should be able to make _pythonRes dynamic: dynamic _pythonRes = source.Execute(_pscope); foreach(dynamic r in _pythonRes) { ... } Whichever works better for you. - Jeff * There used to be some bugs, but they should be long gone. _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ____ The contents of this e-mail and any attachments are confidential and only for use by the intended recipient. Any unauthorized use, distribution or copying of this message is strictly prohibited. If you are not the intended recipient please inform the sender immediately by reply e-mail and delete this message from your system. Thank you for your co-operation. _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com