In this case widget is the string "hello world" so it won't work. If it was instead something like:
class x(object): pass a = x() ... Then in C# you could do: widget = scope.GetVariable("a") then you could do engine.Operations.SetMember(widget, "foo", () => "hello world"); and then back in Python: a.foo() prints hello world. Probably not what you're looking for but it's all that is there today :( From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marty Nelson Sent: Wednesday, November 05, 2008 3:59 PM To: Discussion of IronPython Subject: Re: [IronPython] Extension methods in python >> 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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.
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com