FAQ Database Discussion Community


Python integer unexpected results [duplicate]

python,integer,ironpython
This question already has an answer here: Unexpected floating-point representations in Python 3 answers I am using IronPython 2.7 integrated into Rhinoceros 5 application. I am having a strange int() function result: import math angle = 45.0 tangent = math.tan(math.radians(angle)) n = 12*tangent print "angle: ", angle print "tangent:...

IronPython strange method calling

list,methods,call,instance,ironpython
Why does calling a method like this in ironPython work?: from System.Collections.Generic import List class test: mem = None def __init__(self): # !No Instance created !!! self.mem = List[int] def doSomeThing(self): if self.mem.Contains((List[int](), 123): pass I can't get the behaviour of IronPython in this case: self.mem.Contains((List[int](), 123):. Does any one...

Spotfire Export Automatically

python,ironpython,spotfire
I'm not at all sure that what I need is possible with the tools that I have, but I thought I'd ask. I have the following Python script (technically IronPython, but I don't fully understand the difference), that I pulled from a blog and modified for my purposes: import datetime...

Python module imports Visual Studio

python,visual-studio-2013,ironpython,openpyxl
I have installed openpyxl. Working through the examples in Idle, I encounter no issues. Trying to use my VisualStudio python editor, module imports fail. Does openpyxl need to be added to IronPython for this to work? If so, how?...

Call a Python function with multiple return values from C#

c#,ironpython
This question gives a nice overview of how to call a python function from C# using IronPython. If our python source looks like: def get_x(): return 1 The basic approach is: var script = @" def get_x(): return 1"; var engine = Python.CreateEngine(); dynamic scope = engine.CreateScope(); engine.Execute(script, scope); var...

IronPython in Spotfire: Current Project Path

python,ironpython,spotfire
This should (I think) have a simple answer, assuming that an answer exists. Is it possible to use IronPython to return the path of the current *.dxp project as a string? I use something similar in VBA frequently, and it's become pretty useful. I've tried looking, but I have a...

IronPython entity framwork 6 Could not find attribute where

.net,linq,entity-framework,entity-framework-6,ironpython
I have successfully integrated entity framework into my project. I'm also able to read data from a table over my dbcontext. But when i try to use the linq where method, i get the following error message: 'DbSet[Workflow]' object has no attribute 'Where' This is my code: import clr import...

Passing lists from IronPython to C# (2)

c#,ironpython
There's already a similar answered question in this post but this one is different: I actually do not get a IronPython.Runtime.List (I do have using System.Linq;) from a call like Func<IList<double>> get_a_list = pyOps.GetMember<Func<IList<double>>>(class1, "get_a_list"); where get_a_list is the Python code that returns a Python [] list. I get a...

How do I pass arguments to a Python script with IronPython

c#,python,ironpython
I have the following C# code where I call a python script from C#: using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Windows.Forms; using System.Linq; using System.Text; using System.Threading.Tasks; using IronPython.Hosting; using Microsoft.Scripting.Hosting; using IronPython.Runtime; namespace RunPython { class Program { static void Main(string[] args) { ScriptRuntimeSetup setup =...

C# thread running python script

c#,.net,multithreading,ironpython
I have several python scripts and would like to run them using .net thread pool, each thread running a python script (I have .net doing lot other stuff for me and towards the end needs to call this python script). How can I accomplish this? I could start a process...

Setting field in IronPython resulting in None value

c#,python,.net,ironpython
I have an issue using IronPython. I created a C# DLL in which I have a class that looks like this : namespace MyNamespace { public static class MyClass { public struct Parameters { public String str1; public String str2; public int anIntValue; } public static void MyMethod(Parameters param, out...

How to solve 'Global name self is not defined'?

python,ironpython
This simple code is listening for changes on C:: import clr clr.AddReference('System.IO') from System.IO import (DriveInfo) from WatchDir import WatchedItem from MobileNotifier import MobileNotifier class WinWash(object): ''' Watches the server for important changes. ''' def __init__(self, notifier): self.notifier = notifier self.min_size = 20000 def on_low_space(self, sender, event): ''' Notifies if...

chunk of data into fixed lengths chunks and then add a space and again add them all as a string

regex,list,join,ironpython,findall
I have got hex values as a85b080040010000. I want it to be as a8 5b 08 00 40 01 00 00. I have done it by using below code. But I have to work with very large data. So I want computed time to be very low. import binascii import...

Access C# Enums and Classes from other namespaces in IronPython

c#,.net,enums,namespaces,ironpython
I am stuck on what I would think should be a rather basic feature of IronPython integration with C# (this is, of course, a very simplified example). Below is a simple multi-project solution. The first project defines an enum and a class from one namespace namespace EnumTest { public class...

Python to C# StongBox[Single]

c#,python,ironpython
I've used IronPython to add a reference to a C# dll. I'm attempting to use a method in the DLL which requires an argument of type: out float tempValue When I pass a python float object to the method I get the following traceback: Traceback (most recent call last): File...

Spotfire IronPython script: Delete a data-table

ironpython,spotfire
I am new to iron-python. I would be obliged if anyone can tell me how to completely delete a data-table using iron-python?

IronPython set property value on creating instance (Like c#)

c#,.net,ironpython
Does IronPython supports, to set a property value on creating a new instace. In C# it is possible: SqlParameter param = new SqlParameter() { Value = "123", ... }; Is there a syntax element for this in IronPython? Thank you!...

How to export multiple arrays from IronPython to CSV

python,csv,ironpython
I'm trying to export Two float arrays into a CSV file using IronPython, here's my code import System from System import Array iData = Array.CreateInstance(System.Single, 1024) qData = Array.CreateInstance(System.Single, 1024) import csv with open(r'c:\test.csv', 'w') as fp: writer = csv.writer(fp, delimiter=',') for i in range(0, 1024): val = repr(iData[i]) +...

Compile IronPython with Mono

c#,mono,ironpython
When I try to install IronPython on Debian with Mono (3.12), I get the following error: socket.cs(1900,63): error CS0117: `System.Net.Sockets.SocketOptionName' does not contain a definition for `IPv6Only' How can I solve this problem? According to the IronPython website, everything should compile without errors. In the Mono mailing list there is...

Ubuntu and Ironpython: What paths to add to sys.path AND how to import fcntl module?

python-2.7,ubuntu,mono,ironpython,fcntl
I have latest IronPython version built and running in Ubuntu 14.04 through Mono. Building Ironpython and running with Mono seems trivial but I am not convinced I have proper sys.paths or permissions for Ironpython to import modules, especially modules like fcntl. Running ensurepip runs subprocess, and wants to import "fcntl"....

PyCharm: Shadows built in name 'self', bug or feature?

python,class,pycharm,ironpython,self
I'm using PyCharm IDE; I love it for all the work it does for me. I found it very powerful in my process of learning python. It has all the hints about variables names, typos etc... However now I'm a little bit confused. When using PyCharm with IronPython 2.7, Pycharm...

Ironpython issue with import hook subpackage/submodule

ironpython
I have been struggling with something that I now think may be a bug in IronPython. If anyone could confirm this suspicion or set me straight I would be grateful. The issue I am facing is when trying to apply import hooks using sys.meta_path or sys.path_hooks. IronPython seems to properly...

PythonNet FileNotFoundException: Unable to find assembly

python,python-2.7,ironpython
I am trying to execute a Python script that uses Python For .Net (http://pythonnet.sourceforge.net/) to load a C# library called "Kratos_3.dll" which is in the same folder as the script but the file cannot be found. I have installed clr using "pip install pythonnet". This is my script: import clr...