Python is a high-level, compiled, interpreted language that focuses on code readability.
The language provides tools to program in a object oriented style while using a reduced set of functional tools.
The dominant paradigm in Python is data driven design.
The language-interpreter is available on Windows, MacOS and Linux.
Creating games in Python is generally discouraged, because the language is slow due to the interpreted nature.
While creating games is discouraged, that doesn't mean it is impossible.
Python has many available game libraries to choose from.
Depending on the libraries you choose, you can target some platforms but loose access to another.
There is currently not one library or engine which can ship games to all major platforms.
Due to performance implications, it is recommended to use not all features of Python, but only a subset which runs somewhat performant.
This subset depends on the interpreter you choose.
One way of increasing the performance of your Python game, is to not use Python.
Python provides multiple ways of interfacing with the language from or to other languages.
One of the most popular ways is Cython which provides Python like syntax
while directly getting access to some C capabilities.
Python can currently ship games to PC, Web, Embedded Devices and Mobile.
There are three ways of shipping games written in Python.
If you ship the raw Python code, then this code will run on all environments that have a Python interpreter.
This includes Windows, MacOS, and many Linux distributions.
With this approach it is impossible to ship to mobile, or the web.
When using a bundler, having Python installed is not a requirement anymore.
What most bundlers do, is combining your code with a version of your Python interpreter.
This way the user has only one executable which he can run.
The most popular bundler of Python is py-to-exe
.
Compilation is what allows you to run your code on Embedded Devices and Mobile
For targeting Mobile, you want to use Buildozer in combination with a UI library
that can target mobile devices like Kivy or PyQt.
For targeting Embedded, you want to use Circuit Python.
If you are creating a web application, you will want to use a web-framework like Django or Flask.
Both frameworks support HTML templating.
If your web page needs interactive elements, consider using HTMX or PyScript.
Python has multiple libraries that one can use to make games.
This includes:
Interpreter | Description |
---|---|
C Python | The standard implementation of Python written in C |
PyPy | Due to JIT, programs often run faster and consume less memory. But not all libraries are compatible |
MicroPython | An interpreter that runs on microcontrollers |
For testing web applications, Selenium provides bindings for Python.
Other use cases require setting up a costume testing environment.
missing