IronPython: Accessing the .NET Field

The .NET libraries normally do not expose the public field, but we can still find its’ presence for certain scenarios. IronPython treats the .NET fields like python attribute. For python attribute, the typical operations are set, get and delete. In general, IronPython throws TypeError when deleting members of CLR types and their objects (so for…

0

VisualStudio as my IronPython editor

The following steps are what I did to get Visual Studio ready as my IronPython (and IronRuby) editor. Install the latest internal dogfood build of Visual Studio 2008. you may use Visual Studio 2005 or download the VS 2008 public beta2; Download and install ASP.NET futures release (July 2007). This will give me the nice…

8

IronPython: explicitly choose one method

C# allows method overloading. Given an argument list, the compiler performs the overload resolution to select the best method to invoke. The chosen method token is baked into the assembly. IronPython does the method resolution at the IronPython run time; for most scenarios, it has no problem in picking up the most reasonable one based…

0

IronPython: Provide (or not) Argument for by-ref Parameter

Python function may return multiple objects as a tuple. The .NET method can only return one object as the result of a call; in order to return more than one objects, by-ref parameters are needed. They are decorated with the parameter modifier (ref, out) in C#. Dictionary.TryGetValue(TKey key, out TValue value) has an output parameter…

1

IronPython: Keyword Argument to Set .NET Property/Field

Use keyword arguments to set properties or fields… you likely ask the question: where can we do this? IronPython allows it in the constructor call, the call against the .NET type. Such keyword should be the name of public field, or property (which is not read-only). After creating the object instance, each keyword argument value…

0

IronPython: Passing Arguments for a Call

After getting a CLR type, we can play it like a python type. We can get the class/static methods using the dot operator (“attribute reference”) on the type, or create an instance of it and then get the instance methods. In Python’s word, these methods are callable objects, and we can make “calls” on them…

0