While the word “python” generally refers to a snake, it’s also a programming language! Python can code games as a programming language or perform as a scripting language for larger games. I believe that Python is a good option if you’re a beginner! It’s much easier to understand and it helps create programs in a simple and timely manner.
Benefits of Python:
Python is pretty cool, for a couple of reasons:
- Python’s syntax is more straight forward and readable. Generally, the code that you write will say what’s going on in plain English.
- Python is constantly being worked on and updated to be made better. Because of this, there are multiple versions and revisions to choose from.
- If I haven’t said it enough on this website, Python is great for beginners.
- The Python game library PyGame is also nice for beginners. It’s learning curve isn’t too steep, just like Python.
Disadvantages of Python:
Unfortunately, Python has some disadvantages, as all things do in life 😥
- To be distributed with convenience on Windows, Python games have to use an external tool such as py2exe because the Windows operating system doesn’t include a Python interpreter. Therefore, to avoid having users to have to install Python themselves, a tool such as this one can convert python programs into executable files that Windows can launch on its own. There also are some roadblocks when using these tools that can cause frustration and agony.
- An external tool may also be needed to distribute games on to Macs. Although Mac OS does ship with Python, it’s usually a version that is outdated. To be safe, I recommend a tool like py2app to be used. This is just like py2exe, except it converts to an application that can be run on a Mac OS, since Macs can’t run executable files.
- Since Python is so simple, it’s difficult to work with low-level hardware. For instance, if you wanted to directly edit a variable in a hardware controller, you couldn’t do that with Python. However, since Python works well as a scripting language, it works well with other programming language. So by using a combination of Python and a lower level language, hardware interactions can be made possible. So in short: low level, complicated code can’t be executed with Python alone.
- The first programming language I learned was Python. After I started learning other languages, Python didn’t seem as glamorous to me. It lacks what a lot of other languages have.
Based on the pros and cons of Python, it may be best to use Python if you’re new to game development just to get your feet wet. However, it may not be ideal to commercially release a game with Python. It’s possible, but your time may be spent better elsewhere.
Using Python with IDLE
Python comes packaged with IDLE, an Integrated Development Environment built special for Python. This IDE is notable because when you first look at it, it might seem a little different than other coding environments. The first screen that appears when opening IDLE is an interactive interpreter. The interpreter allows you to type code and execute functions from other modules (Python code files), which can be observed in this image. It makes it super easy to test code and ideas without having to create a separate module.
However, by having the main window of IDLE being the interactive interpreter, the button to create modules and savable programs is a little hidden. In the image, you can see that you create a new file (module) by clicking on File > New Window. From here, you can save your program.
Embedding Python Into Another Programming Language
A cool thing about Python is it can be embedded into another programming language, such as C++. To “embed” Python into another language means that you can use both languages in the same program. This can be extremely useful for games that have extremely complicated physics, graphics, or any other game component. The complicated part of the game can be coded with a lower level language such as C++, then Python can be embedded in to the program to execute more simple functions. Other languages can be embedded into Python as well.
While this sounds enticing, embedding one programming language into another is a pain. For beginner projects, which this site emphasizes, I don’t recommend taking on this task. Although Python includes some nice header files for C++ to use, interfacing the two together isn’t a walk in the park. You can read up about interfacing Python in the Python docs. I don’t encourage you to try to embed languages together until you are an advanced game developer. And besides, most tasks can be accomplished all the same with just one programming language.
Learning How To Program With Python
At this time, my tutorial page doesn’t have any Python tutorials. Until those are made, check out The Python Tutorial that is located in the Python Docs. There are other great resources in those docs, too!