“Eventually I got better – I started making my own mistakes.”

Fun reason to learn Python:-

Python Game:-

Rather more serious tutorial:-

Install pip3

# apt-cache search python3-pip
python3-pip - Python package installer
root@sysmgmt:~# apt-get install python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu b

Data Structures

>>> print ("this is a {LENGTH} {STRING} print").format(LENGTH='short', STRING='test')
this is a short test print
print("Creating '{}' role in account '{}'".format(role_name, event["account_id"]))

Virtual Environment

python3 -m venv <venv name>
$ python3 -m venv stuff-env
# EACH time you will need to run this to avtivate the virtual env:-
$ source stuff-env/bin/activate
(stuff-env) $ 

pip freeze shows current modules, so echo this to requirements.txt to automatically load modules

pip freeze > requirements.txt

To quit the venv, use deactivate command (which venv adds to your path)

$ deactivate

requirements.txt file

Specific versions of packages can be installed from a requirements.txt file, this avoids pip installing a module in a venv which is a later release than the code was written for:-

$ cat requirements.txt
$ pip install -r requirements.txt


rb/python.txt · Last modified: 2021/02/11 13:09 by andrew