Questions tagged [ironpython]

IronPython is an open-source implementation of the Python programming language which is tightly integrated with the .NET Framework. IronPython can use the .NET Framework and Python libraries, and other .NET languages can use Python code just as easily. Use this tag for implementation-specific questions, general Python questions should just be tagged with "python".

IronPython is an open-source implementation of the Python programming language which is tightly integrated with the .NET Framework. IronPython can use the .NET Framework and Python libraries, and other .NET languages can use Python code just as easily.

IronPython can be obtained at http://ironpython.net/.

Comparison of IronPython vs. C# for 'Hello World'

c#:

using System;
class Hello
{
    static void Main() 
    {
        Console.WriteLine("Hello, World");
    }
}

IronPython:

print "Hello, World"

IronPython is a Dynamic Language that runs on the .NET DLR (Dynamic Language Runtime) in contrast with VB.NET and C# which are static languages.

Iron Python can also import DLL files compiled in other languages and use functions defined therein. For example:

import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import *

Chat/Communication

Join our Gitter-Chat under: https://gitter.im/IronLanguages/main

2618 questions
16
votes
6 answers

How to use a C# dll in IronPython

I have created a dll using C#. How do use the dll in IronPython. I have tried to add the dll using clr.AddReference("yxz.dll"). But it fails. I have tried placing the dll in the execution directory of the IronPython script. Still it fails stating…
Prabhu
15
votes
1 answer

How do you implement an interface in IronPython?

The FAQ that comes with IronPython 2.0.1 says the following: You can define interfaces in C#, build those into a DLL, and then implement those interfaces in Python code as well as pass the python objects that implement the interfaces to C#…
Rohit
  • 7,449
  • 9
  • 45
  • 55
15
votes
5 answers

Why is IronPython faster than the Official Python Interpreter

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…
Tristan Havelick
  • 67,400
  • 20
  • 54
  • 64
15
votes
1 answer

How to install packages/modules in IronPython

I am new to IronPython. Thanks for you help and patience. I installed IronPython 2.7 from http://ironpython.net/ in Visual Studio 2015. I also installed Python 2.7.6 and anaconda. I tried the following solution and it didn't work. Installing Python…
Hikaru
  • 151
  • 1
  • 1
  • 3
15
votes
1 answer

Is there a Python equivalent to the C# ?. and ?? operators?

For instance, in C# (starting with v6) I can say: mass = (vehicle?.Mass / 10) ?? 150; to set mass to a tenth of the vehicle's mass if there is a vehicle, but 150 if the vehicle is null (or has a null mass, if the Mass property is of a nullable…
ekolis
  • 6,270
  • 12
  • 50
  • 101
15
votes
4 answers

Best way to detect IronPython

I need to write a module which will be used from both CPython and IronPython. What's the best way to detect IronPython, since I need a slightly different behaviour in that case? I noticed that sys.platform is "win32" on CPython, but "cli" on…
Meh
  • 7,016
  • 10
  • 53
  • 76
15
votes
5 answers

Python - IronPython dilemma

I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them: What is the relationship between Python's C…
Thomas Geritzma
  • 6,337
  • 6
  • 25
  • 19
14
votes
2 answers

GUI development with IronPython and Visual Studio 2010

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…
pinstruct
  • 143
  • 1
  • 1
  • 4
14
votes
2 answers

IronPython invocation from C# (with SciPy) fails with ImportException: "No module named mtrand"

I have a python library I am trying to use via IronPython (v2.7 RC1 [2.7.0.30]) invocation from C# application. The library uses NumPy and SciPy quite extensively, which does work with SciPy and NumPy for .NET when ran using ipy from command line…
PeterParameter
  • 524
  • 5
  • 16
14
votes
2 answers

How to integrate Python Code with C#.Net Core language?

Am trying to integrate python code in my .net core application for data analysis and some machine learning classification. How can I do this the best way? Note: I don't want to execute scripts with IronPython. I already tried that before.
ak2492
  • 305
  • 1
  • 4
  • 14
14
votes
5 answers

How to install numpy and scipy for Ironpython27?

I think this is the most popular way to do it before: https://pytools.codeplex.com/wikipage?title=NumPy%20and%20SciPy%20for%20.Net But this link is no longer exist: https://store.enthought.com/repo/.iron/ I recently found a clone for the…
MacSanhe
  • 2,212
  • 6
  • 24
  • 32
14
votes
5 answers

Python - test a property throws exception

Given: def test_to_check_exception_is_thrown(self): # Arrange c = Class() # Act and Assert self.assertRaises(NameError, c.do_something) If do_something throws an exception the test passes. But I have a property, and when I replace…
Finglas
  • 15,518
  • 10
  • 56
  • 89
13
votes
6 answers

Creating an interactive shell for .NET apps and embed scripting languages like python/iron python into it

I was learning python using the tutorial that comes with the standard python installation. One of the benefits that the author states about python is "maybe you’ve written a program that could use an extension language, and you don’t want to design…
Developer
  • 17,809
  • 26
  • 66
  • 92
13
votes
2 answers

IronPython 3 compatibility

I love the Python language and mainly use the standard CPython 3.+ version for simple scripting and as an algorithm sandbox. Sometimes I need .NET intergration, so I use IronPython which is now in 2.7 version. I like 3.+ better and am therefore…
ver
  • 888
  • 1
  • 8
  • 16
13
votes
2 answers

IronPython sys._getframe not found

I'm currently building a program in C# which will call functions in provided python script files. Some of these script files calls _getframe() in sys, which results in the error: System.MissingMemberException: 'module' object has no attribute …
Nait
  • 1,055
  • 1
  • 14
  • 19