[IronPython] Extension methods in python

Marty Nelson Marty.Nelson at symyx.com
Thu Nov 6 00:58:58 CET 2008

>> If it's an object defined in Python you can usually attach methods
directly to the object or it's Python type. 


So how would this work?


Let's say I had injested a variable into the scope from c#:
scope.SetVarialble("widget", "hello world")


Can I do something in python so that I can then type:


print widget.ToFoo()


print widget.ToBar()


That would theoretically output:


hello worldFoo

hello worldBar



 But otherwise we have no support for automatically adding .NET
extension methods to existing types currently.  It is a frequent request
and we will probably get to it at some point.


From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Marty Nelson
Sent: Wednesday, November 05, 2008 1:50 PM
To: Discussion of IronPython
Subject: [IronPython] Extension methods in python


Is there the equivalent of extension method in python?  I want to put a
variable into the script scope and create extension methods for it.
Does this make sense and is it possible?


Notice: This e-mail message, together with any attachments, contains
information of Symyx Technologies, Inc. or any of its affiliates or
subsidiaries that may be confidential, proprietary, copyrighted,
privileged and/or protected work product, and is meant solely for
the intended recipient. If you are not the intended recipient, and
have received this message in error, please contact the sender
immediately, permanently delete the original and any copies of this
email and any attachments thereto.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20081105/be556dda/attachment.html>

More information about the Ironpython-users mailing list