ironpython

How to host an IronPython engine in a separate AppDomain?

I have tried the obvious: var appDomain = AppDomain.CreateDomain("New Domain"); var engine = IronPython.Hosting.Python.CreateEngine(appDomain); // boom! But I am getting the following error message: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, Version=0.9.0.0, Culture=neutral, Pu...

How can I impersonate the current user with IronPython?

I am trying to manage an IIS7 installation remotely using the Microsoft.Web.Administration library. I'm doing this in IronPython: import Microsoft.Web.Administration from Microsoft.Web.Administration import ServerManager manager = ServerManager.OpenRemote("RemoteServerName") for site in manager.Sites: print "Site: %(site)s" % { '...

Importing external module in IronPython

I'm currently working on an application written in C#, which I'm embedding IronPython in. I generally have no problems about it, but there's one thing that I don't know how to deal with. I want to import an external module into the script. How can I do that? Simple import ext_lib doesn't work. Should I add a path to the lib to sys.path...

What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?

I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code is necessary. I also wanted an IDE with auto-complete and smart indenting. PyScripter seemed like a good option, but can I ru...

TDD with IronPython

Can anyone recommend tools or articles that help me to learn how to TDD IronPython code? ...

How to get to the IronPython Lib directory?

I am embedding IronPython in a C# program. I understand that I need to call ScriptEngine.SetSearchPaths with a list of search paths so that my Python code can import modules. In particular I have to let it know where the standard library modules are, which in my case are here: C:\Program Files (x86)\IronPython 2.0.2\Lib My question is...

Will I be able to use C# 4 as my scripting language?

In one of my C# application I use IronPython as a script language. It looks something like this: string scriptCode = "20 * 5"; ScriptEngine engine = Python.CreateEngine(); ScriptSource source = engine.CreateScriptSourceFromString(scriptCode , SourceCodeKind.Expression); Console.WriteLine(source.Execute<int>()); Will I be able to do...

Embedding IronPython 2 in C# - What is the replacement for DefaultModule.Globals?

I'm trying to convert some IronPython 1 code: var ptype = this.engine.DefaultModule.Globals[ironPythonClassName]; I have a script that declares a class. I use a Python engine to execute the script. How, in IronPython 2 do I get the names of the variables (including the class)? ...

Embedding IronPython - Can't add reference to System

I'm embedding IronPython in my C# application. For some reason I'm having trouble loading assemblies. Specifically, I want System.dll so I can have access to .NET classes like DateTime. If I try the line: _runtime.LoadAssembly(_runtime.Host.PlatformAdaptationLayer.LoadAssembly("System")); I get: could not load file or assembly 'Syst...

Unhandled GeneratorExitException thrown while importing library in embedded IronPython

I have IronPython embedded inside a C# application. I let users write IronPython scripts, in which they can import a set of the standard libraries shipped with IronPython. In these scripts when a user imports the "random" library or the "filecmp" library, an unhandled GeneratorExitException is thrown. Other libraries like math, re, str...

Python - IronPython dilemma

I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them: What is the relationship between Python's C implementation (main version from python.org) and IronPython, in terms of language compatibility ? ...

Trouble importing third party modules when hosting IronPython in SL.

I am hosting Python in a SL app. Basically i have an attached property that lets you pass Python script which then gets executed on the lost focus event of the element. The IPY integration works fine as long as I don't need any 3rd party imports. I copied the formencode package to the site-packages folder under Program Files\Iron Python...

Which IDE do I use to develop a mono app in IronPython?

Hi, I'm investigating which platform to use for a cross platform GUI app that needs access to the serial port. Currently I'm thinking on using the mono runtime and monodevelop as the IDE. However, I already have a corpus of prototype code written python. Therefore, my idea was to write the mono app in IronPython as well, but as far as I...

How to call an IronPython 2 method from C#

I can get an IronPython 2 class back to my C#. What is the new IronPython 2 way of calling a member on that class? object ironPythonClass = scope.GetVariable("Hamish"); object[] args = new object[0]; object pythonObject = engine.Operations.Call(ironPythonClass, args); var member = "Home"; // old way IronPython 1 // var methodResult = ...

Having problem with IronPython to instantiate a class in IronPython Console.

I'm trying to learn IronPython. I created an extremely simple class like this one: class Test: def testMethod(self): print "test" Next I'm trying to use it in IronPython Console: >>> import Test >>> t = Test() After the second line I get following error: TypeError: Scope is not callable What I'm doing wrong? ...

IronPython libraries for scientific plots

What are good python libraries which IronPython supports (current version wise) for drawing scientific plots on Win ? By "scientific plots" I mean simple x-y plots, x-y-z surface plots and x-y-z shaded plots. ...

What IronPython IDE should I use?

This question probably looks a lot like IDE for ironpython on windows question here on stackoverflow. But I read the answers on that question I still have no idea what IDE I should use. What I'm looking for is to know pros and cons of a specific IDE. I recently started learning IronPython. The only IDE I used so far is IronPython Stu...

IronPython studio cannot change default font colors.

I cannot figure out how to change the default colors in Visual Studio for python files. I have a dark gray background color and black Python code doesn't look very good on that background. I looked in Environment->Fonts and Colors in Option dialog but couldn't find the option to change IronPython colors. This question was a sub question...

Generate and parse Python code from C# application.

I need to generate Python code to be more specific IronPyton. I also need to be able to parse the code and load it into AST. I just started looking at some tools. I played with "Oslo" and made decision that it's not the right tool for me. I just looked very briefly at Coco/R and it looks promising. Does any one used Coco/R? If you d...

can you typecast a .NET object in IronPython?

I'm interfacing with a .NET API in IronPython. The API is returning an object of the wrong type (some kind of generic object). I suspect that the problem is not showing up in their C# code because the type declaration when the object is constructed is forcing the returned object to the correct type. Is it possible to typecast an .NET obj...