Python – random bits I can never remember

Dates and times

make sure you ‘include’

import datetime
from datetime import datetime

usage syntax for producing ‘friendly’ date formats is;‘%a, %H:%M’)

for details of strftime usage see

emailing from gmail account 

look at Rpi forum thread – the working version is about 1/2 way through

filename manipulation

Creating zip files


basic motion detection with Python


USB Support

The first line is generally not required as it is installed already, likewise the second only needs be done once.

The upgrade option can be important as earlier versions [below 1.x.x] of pyusb do not have ‘usb.core’ included which will often result in ‘no module named core’ errors where the python code is expecting it.

sudo apt-get install python libusb-1.0
sudo apt-get install python-pip
sudo pip install --upgrade pyusb

Colours in Pygame