ironpython

Pure python implementation of greenlet API

梦想的初衷 提交于 2019-11-28 16:30:42
问题 The greenlet package is used by gevent and eventlet for asynchronous IO. It is written as a C-extension and therefore doesn't work with Jython or IronPython. If performance is of no concern, what is the easiest approach to implementing the greenlet API in pure Python. A simple example: def test1(): print 12 gr2.switch() print 34 def test2(): print 56 gr1.switch() print 78 gr1 = greenlet(test1) gr2 = greenlet(test2) gr1.switch() Should print 12, 56, 34 (and not 78). 回答1: This kind of thing can

Django on IronPython

折月煮酒 提交于 2019-11-28 15:34:47
I am interested in getting an install of Django running on IronPython, has anyone had any success getting this running with some level of success? If so can you please tell of your experiences, performance, suggest some tips, resources and gotchas? Besides the Jeff Hardy blog post on Django + IronPython mentioned by Tony Meyer, it might be useful to also read Jeff's two other posts in the same series on his struggles with IronPython, easy_install and zlib. The first is Solving the zlib problem which discusses the absence of zlib for IronPython; hence, no easyinstall. Jeff reimplemented zlib

IronPython vs. Python .NET

妖精的绣舞 提交于 2019-11-28 15:29:36
问题 I want to access some .NET assemblies written in C# from Python code. A little research showed I have two choices: IronPython with .NET interface capability/support built-in Python with the Python .NET package What are the trade-offs between both solutions? 回答1: If you want to mainly base your code on the .NET framework, I'd highly recommend IronPython vs Python.NET. IronPython is pretty much native .NET - so it just works great when integrating with other .NET langauges. Python.NET is good

Shuffle string c#

爱⌒轻易说出口 提交于 2019-11-28 11:58:17
I want to know shuffle string Example string string word; //I want to shuffle it word = "hello" I would be able to get: rand == "ohlel" rand == "lleho" etc. This solution (in a form of extension method) is nice: public static string Shuffle(this string str) { char[] array = str.ToCharArray(); Random rng = new Random(); int n = array.Length; while (n > 1) { n--; int k = rng.Next(n + 1); var value = array[k]; array[k] = array[n]; array[n] = value; } return new string(array); } C#: string str = "hello"; // The random number sequence Random num = new Random(); // Create new string from the

How to embed IronPython in a .NET application

别来无恙 提交于 2019-11-28 07:46:01
问题 Is it possible to expose an API in a .NET application by embedding a scripting language like IronPython? How is it done? 回答1: IronPython has a hosting API which can be used to execute IronPython scripts from a C#\VB application. This is a good example of embedding IronPython inside a winforms app.Note that the hosting APIs have changed since that post. This post shows an example of the latest API You can find the latest specs here [Note: URL throws a 404 as of 2010-09-07] 回答2: I haven't used

Importing external module in IronPython

你离开我真会死。 提交于 2019-11-28 07:35:09
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 ? Maybe it is possible to copy the lib's .py file into app directory and import from there? EDIT: I finally chosen another solution - compiled my script with py2exe and I'm just running it from main C# app with Process (without using IronPython). Anyway, thanks

Custom IronPython import resolution

一曲冷凌霜 提交于 2019-11-28 07:03:12
I am loading an IronPython script from a database and executing it. This works fine for simple scripts, but imports are a problem. How can I intercept these import calls and then load the appropriate scripts from the database? EDIT: My main application is written in C# and I'd like to intercept the calls on the C# side without editing the Python scripts. EDIT: From the research I've done, it looks like creating your own PlatformAdaptationLayer is the way you're supposed to to implement this, but it doesn't work in this case. I've created my own PAL and in my testing, my FileExsists method gets

How can I import a .PYD module in IronPython?

孤街醉人 提交于 2019-11-28 06:14:27
问题 I'm trying to use a python package from IronPython. Everything works fine if I import regular python modules. But when I try to do the following: import win32ui I get: No module named win32ui I've hunted through the code in IronPython.Runtime.Importer and there's no mention of .pyd Anyone know a way around this? 回答1: You can check out IronClad which is working to provide this support. It may or may not work w/ your PYD of choice. 回答2: A .pyd file is a DLL. So unless IronPython (which is

SSIS: Execute Ironpython or Ironruby scripts through SSIS

一笑奈何 提交于 2019-11-28 04:48:32
问题 Problem! I have a little python script, which goes throught a web page (http-crawling). This web-page is hosted inside the intranet and uses NTLM authentication to gather access to it. So, I found this task (retrieve http-content) easily programmable using python, instead of trying to re-write the whole python script to C# and then use it througth "Script Task" on SSIS, in order to complete the task. Hint! I've looked up closely to SSIS tools and I found that there is a Control Flow named

Debugging IronPython scripts in hosted (embedded) environment

家住魔仙堡 提交于 2019-11-28 03:50:27
I'm writing a C# application which has IronPython (2.0.1) embedded in it. The idea is to expose portions of the application to the IronPython scripts, which the users write. I want to provide the ability to the users to be able to debug the scripts written by them, using the Visual Studio Debugger. Note that the scripts are run in the hosted environment and not through the IronPython executable (ipy.exe). After a bit of Reflector magic on the IronPython assemblies, I came up with something which lets me do that, but I'm not sure if this is the prescribed way. Basically what I do is create a