In current versions of IronPython, DynamicObject is in Microsoft.Scripting.Core as Microsoft.Scripting.DynamicObject.  In .NET 4.0 System.Core, the same class will be called System.Dynamic.DynamicObject.  (I just noticed this naming discrepancy today, and I think we should probably move it to at least Microsoft.<strong>Dynamic</strong> for the 2.6 release.)<br>
<br>
<div class="gmail_quote">On Tue, Apr 14, 2009 at 8:31 AM, Alex News <span dir="ltr">&lt;<a href="mailto:anleewxs@gmail.com">anleewxs@gmail.com</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Much appreciated, I will give that a try.  In what namespace is<br>DynamicObject declared?  (I assume the required assemblies are already<br>
referenced if I&#39;m pulling in IronPython).<br><br>Thanks again,<br><font color="#888888">Alex<br></font>
<div>
<div></div>
<div class="h5"><br><br>On Tue, Apr 14, 2009 at 11:16 AM, Dino Viehland &lt;<a href="mailto:dinov@microsoft.com">dinov@microsoft.com</a>&gt; wrote:<br>&gt; For kwargs you need to decorate the function w/ a ParamDictionary attribute such as:<br>
&gt;<br>&gt; public void __init__(CodeContext/*!*/ context, object o, [ParamDictionary] IAttributesCollection kwArgs)<br>&gt;<br>&gt; For __getattr__ IronPython will recognize a special name &quot;GetBoundMember&quot; method such as:<br>
&gt;<br>&gt; using System;<br>&gt; using System.Runtime.CompilerServices;<br>&gt;<br>&gt; public class Foo {<br>&gt;    [SpecialName]<br>&gt;    public object GetBoundMember (string name) {<br>&gt;        return name;<br>
&gt;    }<br>&gt; }<br>&gt;<br>&gt;<br>&gt; You can also do &quot;GetCustomMember&quot; which is like __getattribute__.  But for this one what you really want to do is inherit directly from the DynamicObject class and override TryGetMember.  Then it&#39;ll work not only w/ Python but w/ other DLR based languages as well (e.g. C#, <a href="http://vb.net/" target="_blank">VB.NET</a>, IronRuby, etc...).<br>
&gt;<br>&gt;<br>&gt;&gt; -----Original Message-----<br>&gt;&gt; From: <a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-">users-</a><br>&gt;&gt; <a href="mailto:bounces@lists.ironpython.com">bounces@lists.ironpython.com</a>] On Behalf Of Alex News<br>
&gt;&gt; Sent: Tuesday, April 14, 2009 7:32 AM<br>&gt;&gt; To: <a href="mailto:users@lists.ironpython.com">users@lists.ironpython.com</a><br>&gt;&gt; Subject: [IronPython] **kwargs and __getattr__ handling in csharp<br>&gt;&gt; functions and classes?<br>
&gt;&gt;<br>&gt;&gt; I would like to write some functions and classes in csharp that<br>&gt;&gt; interact nicely python.  I would like to write a function that can<br>&gt;&gt; respond to keyword arguments, and a class that can dynamically resolve<br>
&gt;&gt; __getattr__.<br>&gt;&gt;<br>&gt;&gt; For the function I tried creating a function that takes a<br>&gt;&gt; IronPython.Runtime.PythonDictionary, but did not work.  For a class I<br>&gt;&gt; tried creating a function that have a method __getattr__, but that<br>
&gt;&gt; failed too.<br>&gt;&gt;<br>&gt;&gt; I see there is a IronPython.Runtime.PythonFunction and some other<br>&gt;&gt; interesting classes in the Runtime, but it is not apparent exactly how<br>&gt;&gt; I could use them.<br>
&gt;&gt;<br>&gt;&gt; I can, luckily, fudge much of what I want to do by creating small<br>&gt;&gt; python classes and functions in python to proxy the values to<br>&gt;&gt; underlying csharp classes.  However thing would be cleaner if I could<br>
&gt;&gt; do it directly in csharp.<br>&gt;&gt;<br>&gt;&gt; Thanks in advance for any suggestions.<br>&gt;&gt;<br>&gt;&gt; Alex<br>&gt;&gt; _______________________________________________<br>&gt;&gt; Users mailing list<br>
&gt;&gt; <a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>&gt;&gt; <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
&gt;<br>&gt; _______________________________________________<br>&gt; Users mailing list<br>&gt; <a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>&gt; <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
&gt;<br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
</div></div></blockquote></div><br>