[IronPython] clr.ImportExtensions are not available outside module ?
jdhardy at gmail.com
Fri May 13 18:27:49 CEST 2011
On Fri, May 13, 2011 at 5:41 AM, daniel kottow <dkottowk at yahoo.com> wrote:
> What I was trying to say that, unfortunately, I do not see a way to encapsulate
> my extension methods written in C# so that a person doing only python does not
> have to worry about it -
> on the other hand, i reckon it is also not such a big deal to write some
> clr.ImportExtensions on the beginning of a module and then the developer *can*
> forget on how the methods got there.
Don't forget that Python is a dynamic language - you can add methods
to the class after it's defined. You might have to inherit from the
.NET class in Python, but then you can loop over the extension methods
and add them to the Python class.
It might be nice to have a clr.ImbueTypeWithExtensions(cls, extcls)
method that did this, and made the extensions available everywhere,
but it would have to be used with care.
More information about the Ironpython-users