Python

Python is a general purpose, high level programming language that very commonly is embedded in large applications to automate some tasks by creating scripts or macros.

In FreeCAD, Python code can be used to create various elements programmatically, without needing the graphical user interface. Additionally, many tools and workbenches of FreeCAD are programmed in Python.

When writing Python code, it's advisable to follow PEP8: Style Guide for Python Code.

Conventions
In this documentation, some conventions for Python examples should be followed.

This is a typical function signature


 * Arguments with key-value pairs are optional, with the default value indicated in the signature. This means that the following calls are equivalent:


 * In this example the first argument doesn't have a default value so it should always be included.


 * When the arguments are given with the explicit key, the optional arguments can be given in any order. This means that the following calls are equivalent:


 * Python guidelines stress readability of code; in particular, parentheses should immediately follow the function name, and a space should follow a comma.


 * If code needs to be broken over several lines, this should be done at a comma inside brackets or parentheses; the second line should be aligned with the previous one.


 * Functions may return a value or object that can be used as the input of another drawing tool.