various bits of Python code