[Python.NET] How to pass a Type to a method?

Daniel Krause m.daniel.krause at googlemail.com
Thu Jan 24 21:11:29 CET 2013


I would like to use System.Array.

The following code is running with iron python

import clr
import System
from System import Array
from System import Int32
from clr import GetClrType
rows = 1
columns = 2
#method: Array.CreateInstance(Type, Int32, Int32)
array = Array.CreateInstance(GetClrType(Int32), rows, columns)
print array.GetLength(0)
print array.GetLength(1)

ouptput:
1
2

The same code throws an import error in python for .NET
    from clr import GetClrType
ImportError: cannot import name GetClrType

Is another syntax for python for .Net necessary?
Or is there perhaps another method to pass a Type to a method?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20130124/4e5693f6/attachment.html>


More information about the PythonDotNet mailing list