| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1ee7031 commit dd2dcd0
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,17 +1,30 @@ | |||
| 1 | 1 | pythonnet | |
| 2 | 2 | ========= | |
| 3 | 3 | ||
| 4 | - Python for .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. | ||
| 4 | + Python for .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. | ||
| 5 | 5 | ||
| 6 | - [](https://ci.appveyor.com/project/TonyRoberts/pythonnet/branch/python3) | ||
| 6 | + [](https://travis-ci.org/pythonnet/pythonnet) | ||
| 7 | 7 | ||
| 8 | - [](https://travis-ci.org/renshawbay/pythonnet) | ||
| 8 | + [](https://ci.appveyor.com/project/TonyRoberts/pythonnet-480xs) | ||
| 9 | 9 | ||
| 10 | - **Features not yet integrated into the main branch**: | ||
| 11 | - - Python 3 support | ||
| 12 | - - Subclassing managed types in Python | ||
| 10 | + **Calling .NET code from Python** | ||
| 13 | 11 | ||
| 14 | - -------------------------------------------------------------------------------------------------------- | ||
| 12 | + Python for .NET allows CLR namespaces to be treated essentially as Python packages. | ||
| 13 | + | ||
| 14 | + ```python | ||
| 15 | + import clr | ||
| 16 | + from System import String | ||
| 17 | + from System.Collections import * | ||
| 18 | + ``` | ||
| 19 | + To load an assembly, use the "AddReference" function in the "clr" module: | ||
| 20 | + | ||
| 21 | + ```python | ||
| 22 | + import clr | ||
| 23 | + clr.AddReference("System.Windows.Forms") | ||
| 24 | + from System.Windows.Forms import Form | ||
| 25 | + ``` | ||
| 26 | + | ||
| 27 | + **Embedding Python in .NET** | ||
| 15 | 28 | ||
| 16 | 29 | + All calls to python should be inside a "using (Py.GIL()) {/* Your code here */}" block. | |
| 17 | 30 | + Import python modules using dynamic mod = Py.Import("mod"), then you can call functions as normal, eg mod.func(args). | |
| Back | FazBrowse Home | New Git URL |
0 commit comments