[Python.NET] Out parameters compatible with IronPython

Urs Fleisch urs.fleisch at gmail.com
Wed Nov 24 10:21:52 CET 2010


The way out and ref parameters are handled is not compatible with
IronPython. In IronPython, out parameters do not have to be provided,
in pythonnet, you always have to pass something (but it is not really
used). The resulting out parameters are returned as return values in
both IronPython and pythonnet, but a void result is always omitted in
IronPython whereas it is only omitted in pythonnet if there is only a
single out parameter.

Example:

To call method "public static void TwoOut(int i, out string sOut, out
int iOut)" you have to use "TwoOut(iIn, sOut, iOut)" in pythonnet with
sOut a string and iOut an int, and you will receive a (void, string,
int) tuple as the return value; in IronPython, you can call
"TwoOut(iIn)" and you get a (string, int) tuple as the result.

I have added a patch at
https://sourceforge.net/tracker/?func=detail&aid=3117417&group_id=162464&atid=823893,
which makes the IronPython behavior available in pythonnet while still
keeping compatibility with the existing behavior.

-Urs


More information about the PythonDotNet mailing list