[IronPython] Magic methods on CLR types

Dino Viehland dinov at microsoft.com
Wed Dec 2 02:57:23 CET 2009


If you want IronPython to recognize them you just need to create an assembly w/ ExtensionTypeAttribute and have it point at the extended and extending types.  Then the assembly needs to be loaded into the ScriptRuntime using ScriptRuntime.LoadAssembly.

We still need to figure out our story for recognizing and importing normal .NET extension methods that C# supports.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeffrey Sax
Sent: Tuesday, December 01, 2009 5:27 PM
To: 'Discussion of IronPython'
Subject: [IronPython] Magic methods on CLR types

Is there a way to add magic methods like __repr__, __call__, etc. to CLR types?


1.       Can it be done in the external CLR assembly without polluting the API for other languages? If so, how?

2.       Can it be done using F# style type augmentations by redefining such methods on the Python type corresponding to the CLR type? If so, how?

3.       If neither of these alternatives is possible, is there a third way?

Thanks!

Jeffrey Sax
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20091202/6993fb39/attachment.html>


More information about the Ironpython-users mailing list