1
votes

Everything works fine in Python 2, but in Python 3, it doesn't work. I installed the package using the whl from Gohlke's Python packages. The problem is, in Python 3, all integers are long. When passed to a C# function, they're passed as 64 bit integers, which causes functions that take Int32 as an argument to fail with the error "No method matches given arguments". I tried to convert it to Int32 with Convert.ToInt32(), but that returns a Python int, which is 64 bit again.

So, the question is, how do I use Int32 properly in Python3?

Oh, and when I tried it like this it did an OverflowError:

>>> print(Int32(2))
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    print(Int32(2))
OverflowError: value too large to convert
1

1 Answers

0
votes

Unint32 or Int32 need to be loaded from System:

import clr
clr.AddReference("System")
from System import UInt32, Int32

print(UInt32(2))
print(Int32(2))