Python.NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers. It allows Python code to interact with the CLR, and may also be used to embed Python into a .NET application.
Note
The master branch of this repository tracks the ongoing development of version 3.0. Backports of patches to 2.5 are tracked in the backports-2.5 branch.
Python.NET allows CLR namespaces to be treated essentially as Python packages.
import clr
from System import String
from System.Collections import *
To load an assembly, use the AddReference
function in the clr
module:
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Form