[IronPython] IronPython 1.1.2 and overloaded or generic methods

Dino Viehland dinov at microsoft.com
Wed Nov 12 03:35:49 CET 2008

I think you want to do:


I think the 2nd two will be equivalent but just perform the operations in a different order.  The 1st should give you a generic method which has both overloads.

Overloads is for selecting one of the various methods.  So you have 3 things to index into:
        The generic type, to provide it's type parameters
        The generic method, to provide the method's type parameters
        The Overloads, to select an individual method out of the set of overloaded methods.

There still might be a generic constraint that you're violating though.  Looking at the API my guess would be that there is a constraint that the object must implement new.   You might try:


as object contains a default constructor.  If that doesn't work then you'll need to get the constraints which should be in the docs or you could open the assembly with reflector.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jason Galyon
Sent: Tuesday, November 11, 2008 5:43 PM
To: users at lists.ironpython.com
Subject: [IronPython] IronPython 1.1.2 and overloaded or generic methods

I am new to IronPython with absolutely no knowledge yet of .NET/CLR.
I am trying to use IronPython with a new API from a particular system
where the methods are overloaded as you can see below from the
interactive prompt.
How do I call a particular method with the signature I want?

Secondary question is whether there will ever be a more Pythonic way of
dealing with these?

Thanks in advance for any information!

IronPython 1.1.2 (1.1.2) on .NET 2.0.50727.3053
Copyright (c) Microsoft Corporation. All rights reserved.
... add reference and importing ...
 >>> rancore.Repository.ElementRepository.CreateAdapterForPath.Overloads
<IronPython.Runtime.Calls.BuiltinFunctionOverloadMapper object at
0030 [{'T CreateAdapterForPath[T](str path)': <built-in function
rPath>, 'T CreateAdapterForPath[T](str path, int timeout)': <built-in
function C
]('/form[@title="System\ Requirements\ -\ Mozilla')
Traceback (most recent call last):
  File , line 0, in <stdin>##79
ValueError: GenericArguments[0], 'System.String', on 'T
System.String)' violates the constraint of type 'T'.
Users mailing list
Users at lists.ironpython.com

More information about the Ironpython-users mailing list