This section covers all general things about Python and things, which do not belong to any of the other categories.
I generally recommend installing Python via binary from python.org. However, since Microsoft allows you to install Python via the Windows Store, it’s highly recommended for Windows users to install Python this way. There are a lot advantages of this approach.
Note: As a Mac or Linux user, you may want to add the following alias to your
.zshrcas most systems come with Python 2 installed by default and
pythonpoints to the Python 2 installation:alias python='python3'
1.2. Read-Eval-Print Loop (REPL)¶
The Read-Eval-Print Loop (REPL) ships with your Python installation.
In fact, if you enter
python in your console, the REPL should start.
The idea behind the REPL is, that you get immediate feedback about the commands you’ve entered.
Whenever you see
>>> in the code examples, you can be sure, that the code is executed in the REPL.
Otherwise the code will be part of a script.
>>> 5 5
If you want to run a Python file via command-line, simply run:
$ python <filename>
$ python my_file.py
1.4. Naming Conventions¶
Note: As described in the previous paragraph, PEP 8 does also specify code formatting guidelines. However, if you want to use a code formatter, I can highly recommend Black.