Using Python for .NET

Unlike CPython, Python for .NET provides no interactive session. Thus, all Python programs must be saved as .py files and compiled using the Python for .NET compiler. By default, the compiler will generate an executable that can be run, but compiler options allow a variety of options. Invoking the compiler with a -help option will show all supported options.

The compiler itself can be downloaded from the official Web site (http://www.python.org). CPython, the Python for Win32 extensions, and the .NET SDK (for the C# compiler) are all required; see the readme file for more information.

Example: Hello World

The simplest Python program is

print "Hello, world" 

Assuming this code is saved as hello.py, we can compile the program ...

Get Programming in the .NET Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.