How to use "out" or "ref" on method parameter list
I have a DotNet class with methods with the following signature: public bool MyMethod(out int myVariable) { myVariable = 5; return true } Does anybody know how I cancall them from Python via CLR? I've tried MyMethod(a), where a has been an empty list, a list with one element, an integer etc, but nomatter what i get an error saying TypeError: no method matches given arguments Can anybody help? Jill
Hi Jill - Python for .NET doesn't yet handle in, in/out, ref etc. parameters yet. This is one of the (surprisingly few) places where the Python model doesn't match well with .NET. In the future, I expect that Python will return a tuple of (result, outparam, outparam...) to handle out params, but its not there yet. A quick workaround would be to implement a helper method that calls MyMethod and returns the modified int as its result, then call that from Python. (If you need both the bool result and the int, you could return a struct, etc.) Hope this helps! Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com -----Original Message----- From: pythondotnet-bounces@python.org [mailto:pythondotnet-bounces@python.org]On Behalf Of Jill-Connie Lorentsen Sent: Thursday, March 25, 2004 7:26 AM To: pythondotnet@python.org Subject: [Python.NET] How to use "out" or "ref" on method parameter list I have a DotNet class with methods with the following signature: public bool MyMethod(out int myVariable) { myVariable = 5; return true } Does anybody know how I cancall them from Python via CLR? I've tried MyMethod(a), where a has been an empty list, a list with one element, an integer etc, but nomatter what i get an error saying TypeError: no method matches given arguments Can anybody help? Jill
participants (2)
-
Brian Lloyd
-
Jill-Connie Lorentsen