ironpython

IronPython: Changing behaviour of SourceCodeKind.InteractiveCode

风流意气都作罢 提交于 2019-12-12 18:04:39
问题 I can execute IronPython in C# with: ScriptSource Source = PyEngine.CreateScriptSourceFromString(Code, SourceCodeKind.InteractiveCode); CompiledCode Compiled = Source.Compile(); Compiled.Execute(PyScope); This means that I can execute A=1 and then A . This will then output 1 . Is there a way I can override this behaviour so A will be redirected to a C# function, say CustomPrinter before printing? I know I can 'overload' the print function as described by https://stackoverflow.com/a/13871861

How can I get the externalname of a column using IronPython in Spotfire?

早过忘川 提交于 2019-12-12 17:26:37
问题 Currently I need to change the name of a column depending on specific criteria but to do that I'd like to refer to that column by its ExternalName rather than its name. aColumn = Document.ActiveDataTableReference.Columns["I_id"].Name unfortunately this doesn't work. aColumn = Document.ActiveDataTableReference.Columns["I_id"].ExternalName 回答1: you're very close! ExternalName isn't a property of the DataColumn object, which is, I suppose you've figured out, why your approach isn't working. in

No module named fcntl

亡梦爱人 提交于 2019-12-12 17:18:06
问题 I am trying to execute this method with IronPython on .NET 4.0 using IronPython 2.7. i am using Windows 7 import os import re import nltk import urllib import xapian import sys def getData(url): try: html = urllib.urlopen(url) text = html.read() html.close() except: return "error" try: return nltk.clean_html(text) #takes the tokens except: return text C# CODE: public static object Execute() { string scriptPath = "Calculator.py"; ScriptEngine engine = Python.CreateEngine(); engine

TranslateTransform for drag and drop in Silverlight

拜拜、爱过 提交于 2019-12-12 16:19:20
问题 We're trying to implement drag and drop in Silverlight (3). We want users to be able to drag elements from a treeview onto another part of a UI. The parent element is a Grid, and we've been trying to use a TranslateTransform along with the MouseLeftButtonDown, MouseMove (etc) events, as recommended by various online examples. For example: http://www.85turns.com/2008/08/13/drag-and-drop-silverlight-example/ We're doing this in IronPython, but that should be more or less irrelevant. The drag

Why can't IronPython be installed with Visual Studio 2010?

核能气质少年 提交于 2019-12-12 10:32:14
问题 IronPython has been out for a while now, so when I installed Visual Studio 2010 RC1 "Ultimate" this morning I was surprised to find that it couldn't be selected from the installer. Instead, one still has to go out to Codeplex. Does anybody know why it hasn't been included? 回答1: This is what I have picked up from the IP mailing list... Ironpython is on a different release cycle to Visual Studio and developed by a separate team. The MS G.O. team development process is far more responsive and

How to add modules to Iron Python?

人盡茶涼 提交于 2019-12-12 10:07:40
问题 I have been trying to execute following Python code (graphcreater.py) using C# Visual Studio. I added IronPyton 2.7.7 and IronPython.StdLib 2.7.7 via NuGet package manager. Once I run the program it gives an exception saying that, No module named mpl_toolkits.mplot3d I need to figure out how to import mpl_toolkits module in Python code (graphcreater.py) correctly. NOTE: The graphcreater.py is running when executed using Python only. Python Code (graphcreater.py): from mpl_toolkits.mplot3d

Constantly reading from a serial port with a background thread

浪尽此生 提交于 2019-12-12 08:56:37
问题 As serial port communication is asynchronous, I figured out early on into my project involving communication with a RS 232 device that I will have to have a background thread constantly reading the port for data received. Now, I'm using IronPython (.NET 4.0) so I have access to the slick SerialPort class built into .NET. This lets me write code like this: self.port = System.IO.Ports.SerialPort('COM1', 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One) self.port.Open() reading

IronPython DSL casting constants to C# types

不想你离开。 提交于 2019-12-12 06:30:09
问题 I am implementing a DSL in IronPython. Suppose I have a value hierachy implemented in C# to be used in iron python: public abstract Value { } public abstract DoubleValue : Value { // Constructors... public double magnitude; // Arithmetic operators overloaded... } public abstract FractionValue : Value { // Constructors.... public int numerator; public int denominator; // Arithmetic operators overloaded... } Due to the operator overloading in C#, i can do this in Python: # a, b are of type

How can I enable sys._getframe in IronPython 2.6.1?

一笑奈何 提交于 2019-12-12 05:02:00
问题 I'm trying to use a module that requires sys._getframe(), which, as I understand it, is not enabled by default. I've seen a lot of material that suggests that there is a way to enable _getframe(), but I've yet to find anything that tells me how to do so. What is the proper method for enabling this function in IronPython 2.6.1? Does one even exist? Thanks in advance. 回答1: Resolved. Turns out that you need to rebuild IronPython from source, with the command line options –X:Frames or –X

How to install openpyxl within IronPython

故事扮演 提交于 2019-12-12 03:12:24
问题 I was trying to install openpyxl using the setup.py which in turn uses setuptools. Unfortunately, setuptools cannot be installed within IronPython and I would like to know what other options exist. 回答1: You can download it directly from: https://bitbucket.org/openpyxl/openpyxl/src/default/ and include it on your python path. 来源: https://stackoverflow.com/questions/9980785/how-to-install-openpyxl-within-ironpython