ironpython

IronPython ScriptRuntime equivalent to CPython PYTHONPATH

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The following import works inside ipy.exe prompt but fails using IronPython ScriptRuntime inside a C# 4.0 program. import ConfigParser C# code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using IronPython.Hosting; using Microsoft.Scripting.Hosting; namespace CSharpDynamic { class Program { static int Main(string[] args) { ScriptRuntime python = Python.CreateRuntime(); dynamic dynamicIni = python.UseFile(@"c:\test\WebCast\DynamicIni.py"); return 0; } } } CPython uses PYTHONPATH environment variable.

Visual Studio IronPython CPython

北城以北 提交于 2019-12-02 23:39:32
安装 IronPython - 张善友 - 博客园 https://www.cnblogs.com/shanyou/archive/2006/09/14/504580.html VS2017作为python开发的IDE - 云+社区 - 腾讯云 https://cloud.tencent.com/developer/article/1339749 pypy -- 用python实现的python - 张善友 - 博客园 https://www.cnblogs.com/shanyou/archive/2007/04/25/727557.html CPython 和IronPython的基准测试 - 张善友 - 博客园 https://www.cnblogs.com/shanyou/archive/2007/04/25/727423.html 来源: https://www.cnblogs.com/rgqancy/p/11510643.html

IronPython

匿名 (未验证) 提交于 2019-12-02 22:51:30
当时做FitnesseTest的时候,写了很多和硬件交互的代码,但是后来发现每次都通过启动进程的方式运行python脚本,很费时间。 既然要运行python脚本,在.net平台下可以用IronPython来试一下。 同事说她试过了,有很多错误,无法执行。 后来我发现确实有很多warning,但可以运行,后来把代码放进系统测试,还不错。 因为内部保存了连接,这样就不需要每次再建立连接,最后大概提升20%的性能。 性能提升不算多,不过得到了锻炼,很值得。

C# / IronPython Interop with shared C# Class Library

倖福魔咒の 提交于 2019-12-02 21:18:41
I'm trying to use IronPython as an intermediary between a C# GUI and some C# libraries, so that it can be scripted post compile time. I have a Class library DLL that is used by both the GUI and the python and is something along the lines of this: namespace MyLib { public class MyClass { public string Name { get; set; } public MyClass(string name) { this.Name = name; } } } The IronPython code is as follows: import clr clr.AddReferenceToFile(r"MyLib.dll") from MyLib import MyClass ReturnObject = MyClass("Test") Then, in C# I would call it as follows: ScriptEngine engine = Python.CreateEngine();

How to match two arrays

谁说胖子不能爱 提交于 2019-12-02 20:55:49
问题 I have two arrays A = [a, b, c, d] and B = [a1, a2, b1, b2, b3, c1, c2, c3, d1, d2, d3, d4] I want to match between the two arrays. Match Result: [a : a1, a2] [b : b1, b2, b3] [c : c1, c2, c3] [d : d1, d2, d3, d4] 回答1: In pretty Python: di = {} for item in A: di[item] = filter(lambda v: v.startswith(item), B) 回答2: These solutions works fine both in python and IronPython . Imperative solution: A = ["a", "b", "c", "d"] B = ["a1", "a2", "b1", "b2", "b3", "c1", "c2", "c3", "d1", "d2", "d3", "d4"]

What are some strategies to write python code that works in CPython, Jython and IronPython

我与影子孤独终老i 提交于 2019-12-02 20:45:59
Having tries to target two of these environments at the same time I can safely say the if you have to use a database etc. you end up having to write unique code for that environment. Have you got a great way to handle this situation? If you do find you need to write unique code for an environment, use pythons import mymodule_jython as mymodule import mymodule_cpython as mymodule have this stuff in a simple module (''module_importer''?) and write your code like this: from module_importer import mymodule This way, all you need to do is alter module_importer.py per platform. @Daren Thomas: I

Reading the contents of Microsoft Visio (2010) doc in IronPython

别说谁变了你拦得住时间么 提交于 2019-12-02 19:41:10
问题 I have an assignment to write a program in IronPython, that reads a Visio (2010) Document, and outputs in CMD what objects are in the active page, and how they are connected to each other. So far, I have managed to open the Visio Document, but I can't display what's in it. This is my code until now: import sys import clr import System clr.AddReference("Microsoft.Office.Interop.Visio") import Microsoft.Office.Interop.Visio IVisio = Microsoft.Office.Interop.Visio visapp = IVisio

Sandbox IronPython?

偶尔善良 提交于 2019-12-02 19:34:17
Is it possible to run an IronPython interpreter inside my .Net application, but inside a sandbox? I want to deny the IP script access to the filesystem while still allowing the app itself access. Would this involve running the scripting engine in a second AppDomain? How would I handcuff it so it can't do whatever it pleases? Here's an article explaining how to create an AppDomain and execute code in a sandbox . Just create the AppDomain and handcuff the code that runs inside it. 来源: https://stackoverflow.com/questions/4393153/sandbox-ironpython

IronPython in Unity3D

一曲冷凌霜 提交于 2019-12-02 19:02:43
I am trying to use IronPython as an external scripting language for Unity3D. The necessary DLLs for IronPython's execution load just fine inside of Assets\Plugins. However, when I try to run the script I get this error: PythonImportErrorException: No module named UnityEngine IronPython.Modules.Builtin.__import__ (IronPython.Runtime.Calls.ICallerContext,string,object,object,object) <IL 0x0003b, 0x001cc> (wrapper dynamic-method) object.__import__##5 (IronPython.Runtime.Calls.ICallerContext,object,object,object,object) <IL 0x0000e, 0x0004d> IronPython.Runtime.Calls.FastCallableWithContextAny.Call

How to use IronPython with Visual Studio 2008

ε祈祈猫儿з 提交于 2019-12-02 16:51:45
I've tried using the IronPython integration extension provided by Microsoft. But it does not work with Visual Studio 2008. Is there a proper VS 2008 IDE extension for IronPython? For IronPython 1.1 support (whose syntax mirrors CPython 2.4), I successfully built and installed the sample from the Visual Studio 2008 SDK 1.0 with the Professional Edition of Visual Studio 2008 SP1. It will work with any edition from Standard up to Team Suite. It definitely won't work with Express Edition due to limitations built in to Express. For IronPython 2.0 (whose syntax mirrors CPython 2.5), there is