Skip to content

Latest commit

 

History

History

README.md

IronPythonExamples - Running Python from .NET with IronPython Integration

YouTube Blog Newsletter All Links LinkedIn

This .NET Framework 4.0 solution demonstrates five different approaches to integrating Python with C# applications using IronPython 2.7.4. The projects range from simple console output to a full Windows Forms GUI: PrintToConsole executes inline Python print statements, RunExternalScript loads and runs external .py files, DynamicScript creates Python classes from inline scripts and calls their methods from C#, DynamicClass shows runtime property manipulation on Python objects, and SampleForm provides a WinForms application for interactive Python script execution with output redirection to a TextBox.

Each project demonstrates key IronPython integration patterns including engine creation with Python.CreateEngine(), script execution with Execute() and ExecuteFile(), scope management for variable isolation, dynamic object binding using C#'s dynamic keyword, and I/O stream redirection for capturing Python output. This is a comprehensive reference for developers looking to embed Python scripting capabilities in their .NET applications.

Getting Started

Prerequisites

  • .NET Framework 4.0 or later
  • IronPython 2.7.4 (installed via NuGet)

Running the Project

Open the solution in Visual Studio and run any of the five example projects.

Related Resources

Blog Articles

Newsletter

If you found this useful and you want to learn more about C#, .NET, and software engineering, subscribe to the free Dev Leader Weekly newsletter:

Subscribe to Dev Leader Weekly

Connect with Dev Leader


BrandGhost

Powered by BrandGhost 👻