[Python.NET] How to pass a Type to a method?
Tribble, Brett
btribble at ea.com
Thu Jan 24 22:27:04 CET 2013
I don't think the python.net clr module supports most of the methods etc. that the IronPython one does:
http://nullege.com/codes/search/clr
Can you use the following instead?
import System
...
...
array = Array.CreateInstance(System.Int32, rows, columns)
From: PythonDotNet [mailto:pythondotnet-bounces+btribble=ea.com at python.org] On Behalf Of Daniel Krause
Sent: Thursday, January 24, 2013 12:11 PM
To: pythondotnet at python.org
Subject: [Python.NET] How to pass a Type to a method?
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/06be11b4/attachment.html>
More information about the PythonDotNet
mailing list