Python

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

Formatting

>>> print ("this is a {LENGTH} {STRING} print").format(LENGTH='short', STRING='test')
this is a short test print
>>> 

Virtual Environment

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

pip freeze > requirements.txt

Lists and Dicts

List

uses comma as sep and square brackets

list = ["value1", "value2"]

Dictionary

uses “:” and curly brackets

dict = { "key1": "value1", "key2": "value2" }

rb/python.txt · Last modified: 24/06/2019 11:13 by andrew