ironpython

Integration of python in C# Application

混江龙づ霸主 提交于 2019-11-29 04:09:42
I have the following problem: I got an old application which is written in python. This application allows the user to specify small python steps which will be executed, python steps are basically small python scripts, I call them steps because the execution of this application involves other steps like executing something from commandline. These python steps are stored as python code in an xml file. Now I want to rewrite the application by using C# .NET. Is there a best practise solution to do something like this? I don't want to call python as external programm and pass the actual python

Why is IronPython faster than the Official Python Interpreter

耗尽温柔 提交于 2019-11-29 03:34:28
问题 According to this: http://www.codeplex.com/IronPython/Wiki/View.aspx?title=IP20VsCPy25Perf&referringTitle=IronPython%20Performance IronPython (Python for .Net) is faster than regular Python (cPython) on the same machine. Why is this? I would think compiled C code would always be faster than the equivalent CLI bytecode. 回答1: Python code doesn't get compiled to C, Python itself is written in C and interprets Python bytecode. CIL gets compiled to machine code, which is why you see better

Execute query on SQL Server Analysis Services with IronPython

青春壹個敷衍的年華 提交于 2019-11-29 02:42:57
I was able to connect to SQL server Analysis service in Python using Microsoft.AnalysisServices.dll , and now I can't execute query on cube. I've tried Execute method same as following: amoServer.Execute('select from finance') After issuing Execute method I have this error: <Microsoft.AnalysisServices.XmlaError object at 0x000000000000002B [Microsoft.AnalysisServices.XmlaError]> Note: I'm using IronPython with Python 2.7 on Windows Server 64Bit. What's the problem? its better use Microsoft.AnalysisServices.AdomdClient.dll and mdx query. and set query result in Datasets in Ststem.Data assembly

GUI development with IronPython and Visual Studio 2010

那年仲夏 提交于 2019-11-29 02:32:09
问题 I'm teaching an introductory class to programming and GUI development using Python, and have found that the least overwhelming solution for students new to programming is to use Visual Studio for GUI development. While the GUI development experience with C# and VB is pleasant, I couldn't find a way to do the same with IronPython. I installed IronPython 2.7.1 which includes the Visual Studio tools, and created a WPF IronPython project. I can use the WPF form designer just like VB and C#,

How to use Microsoft.Scripting.Hosting?

匆匆过客 提交于 2019-11-29 02:04:24
To embed some IronPython Code into C# I want to use the ScriptEngine using IronPython.Hosting; using Microsoft.Scripting.Hosting; I found the reference for IronPython, but where is the necessary reference for Scripting.Hosting? I can't find it within VisualStudio 2008, targeting .Net 3.5. It looks like this is part of the DLR binaries ... more information here: https://blogs.msdn.com/seshadripv/archive/2008/06/24/how-to-write-a-simple-dlr-host-in-c-using-hosting-api.aspx The DLR is actually broken into 2 parts: the "inner layer" which is included in .NET 4.0 and is part of System.Core.dll (and

Empty list is equal to None or not? [duplicate]

雨燕双飞 提交于 2019-11-29 01:00:27
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Why does “[] == False” evaluate to False when “if not []” succeeds? I am new to python as per ternary operator of python >>> 'true' if True else 'false' true true i am expecting for below code output as [] because [] not equal to None >>> a=[] >>> a==None False >>> a if a else None None pleas correct if i am wrong Thanks hema 回答1: The empty list, [] , is not equal to None . However, it can evaluate to False -

Compiling an IronPython WPF project to exe

白昼怎懂夜的黑 提交于 2019-11-29 00:45:32
问题 What is the best way to pack up an IronPython application for deployment? After scouring the web the best thing I've come up with (and what I'm currently doing) is using clr.CompileModules() to glue together my entire project's .py files into one .dll, and then having a single run.py do this to run the dll: import clr clr.AddReference('compiledapp.dll') import app This is still suboptimal, though, because it means I have to distribute 3 files (the .dll , the .xaml , and the run.py launcher)

Powershell window disappears before I can read the error message

核能气质少年 提交于 2019-11-28 23:50:14
问题 When I call a Powershell script, how can I keep the called script from closing its command window. I'm getting an error and I'm sure I can fix it if I could just read the error. I have a Powershell script that sends an email with attachment using the .NET classes. If I call the script directly by executing it from the command line or calling it from the Windows Scheduler then it works fine. If I call it from within another script (IronPython, if that matters) then it fails. All scenarios work

passing Lists from IronPython to C#

不羁的心 提交于 2019-11-28 21:07:31
问题 I want to pass a list of strings from IronPython 2.6 for .NET 2.0 to a C# program (I'm using .NET 2.0 because I'm working with an api that runs off of DLLs built on 2.0). But I'm not sure how to cast it as it comes back from the ScriptEngine. namespace test1 { class Program { static void Main(string[] args) { ScriptEngine engine = Python.CreateEngine(); ScriptSource source = engine.CreateScriptSourceFromFile("C:\\File\\Path\\To\\my\\script.py"); ScriptScope scope = engine.CreateScope();

Slicing a dictionary by keys that start with a certain string

纵饮孤独 提交于 2019-11-28 20:06:11
This is pretty simple but I'd love a pretty, pythonic way of doing it. Basically, given a dictionary, return the subdictionary that contains only those keys that start with a certain string. » d = {'Apple': 1, 'Banana': 9, 'Carrot': 6, 'Baboon': 3, 'Duck': 8, 'Baby': 2} » print slice(d, 'Ba') {'Banana': 9, 'Baby': 2, 'Baboon': 3} This is fairly simple to do with a function: def slice(sourcedict, string): newdict = {} for key in sourcedict.keys(): if key.startswith(string): newdict[key] = sourcedict[key] return newdict But surely there is a nicer, cleverer, more readable solution? Could a