Skip to content

Python

Example projects

venv

Virtual environments out of the box.

Activate a new venv with the following (which will create a local directory called venv based on the name of the large arg):

python3 -m venv venv

From this point you can activate the environment via

source venv/bin/activate

You'll then be good to install any local requirements, etc (e.g. pip install -r requirements.txt).

Note that you can deactivate by simply running deactivate.

Samples

  import turtle   
  colors=['red', 'purple', 'blue',
          'green', 'yellow', 'orange']
  t=turtle.Pen()
  turtle.bgcolor('black')
  for x in range(1000):
      t.pencolor(colors[x%6])
      t.width(x/100+1)
      t.forward(x)        
      t.left(59)

Local webserver

# If Python version returned above is 3.X
# On Windows, try "python -m http.server" or "py -3 -m http.server"
python3 -m http.server
# If Python version returned above is 2.X
python -m SimpleHTTPServer