12.11.1 Getting started with Haxe/Python

To get started with Haxe/Python, create a new folder and save this class as Main.hx.

    Multi-line comments for documentation.
class Main {
    static public function main():Void {
        // Single line comment
        trace("Hello World");

To compile, either run the following from the command line:

haxe --python hello.py --main Main

Another possibility is to create and run (double-click) a file called compile.hxml. In this example the hxml file should be in the same directory as the example class.

--python hello.py
--main Main

The compiler outputs a file called hello.py in the current folder, which can be executed with python hello.py (or python3 hello.py in case Python 2 is the default on the system) from the command line.