Write a Hello World application with Python

  1. Launch Geany. From the desktop, select Applications > Development > Geany.

  2. Select Project > New. Name the project hello_world_python.

    The fields represent the following:

    • Name — The name of the project.
    • Filename — The filepath of the project, where the project settings are stored. This path generally ends in .geany
    • Base path — The base path of all files making up the project.


  3. Click OK when prompted to create the directory.

  4. Write a Hello World sample application. This example uses:

    import sys
    
    if __name__ == '__main__':
            printf("Hello World!")
    
        sys.exit(0)
  5. Select File > Save As, and save it as hello_world.py

  6. Select Build > Compile to compile the source.

  7. Select Build > Build to create an executable for the code.

  8. Select Build > Execute to execute the code in a terminal window:



  9. Try the linting function by adding spaces in front of the print statement.

  10. Select Build > Lint. You should see an indentation error:



  11. Remove the extra spaces, and the code should lint successfully:



  12. Next, try debugging the Hello World sample. Set a breakpoint in your code by adding the breakpoint() function before the print statement:



  13. Select Build > Execute to start the debugger. Geany opens a terminal, starts the pdb debugger, and stops at the breakpoint. Use the commands n (next), s (step), or c (continue) to navigate through the code:



Next steps

The default commands for Python files are overridden for the user currently in /home/qnxuser/.config/geany/filedefs.

For more information on how to modify the default commands, refer to the "Adjusting build commands" section in the "Customizing Geany" page.

For more information on how to customize the lint commands, refer to the pycodestyle documentation at https://pycodestyle.pycqa.org/.

Page updated: