[IronPython] Casting python list type to NET type

Michael Foord fuzzyman at voidspace.org.uk
Fri May 25 01:35:12 CEST 2007


Filipe Silva wrote:
> Hi all,
>
> I've an VB.NET application invoking some python functions and I would
> like these functions to return a list type.
>   
To use the return values from other .NET languages like VB.NET and C# I 
think you have little choice but to use a .NET collection.

You could make this conditional by wrapping the import in a 'try.. 
except' and having different behaviour on platforms where the .NET type 
is not available (i.e. CPython).

Michael Foord
http://www.voidspace.org.uk/ironpython/index.shtml

> I've already tried to cast the result from "list" (python) to
> Collection (VB.NET), also to ArrayList and to a simple string array.
> In all cases I receive a cast exception saying that it's not possible
> to make that conversion...
>
> Is there any NET type that could be directly casted from ironpython list type?
>
> Note:
>  1. I can return a String instead of a list, but I would need to parse
> that string inside VB.NET (using some kind of token)
>
>  2. I've found a solution by importing System.Collections.ArrayList in
> my python script, then using ArrayList object instead of native list
> type, however this way, my script doesn't work in a different engine
> (that one in www.python.org, for instance)
>
>
> Thanks,
> Filipe
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>   




More information about the Ironpython-users mailing list