[Python.NET] How to get 'None' from .NET?

Boris Capitanu borice23 at yahoo.com
Thu Apr 14 20:37:47 CEST 2005


I'm trying to call from .NET some function defined in
a Python script, and pass 'null' as one of the
parameters of the function in certain situations. I
was expecting that the bridge would map the 'null' in
.NET to 'None' in Python, however I receive an
exception in .NET when I execute the code.

I have something like the following:

1. PyObject module =
2. PyObject func = module.GetAttr("someFunction")

3. object aNullObject = null

4. PyObject[] arguments = new PyObject[2]
5. arguments[0] = PyObject.FromManagedObject("a
6. arguments[1] =
  // I also tried: arguments[1] = null directly

8. func.Invoke(arguments)

When executed, line 6 throws a NullReferenceException
if I use 'arguments[1] = null' instead of line 6, I
get a NullReferenceException in line 8.

How can I pass 'null' to a script?

Thank you.


Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!

More information about the PythonDotNet mailing list