Use python idioms (list comprehensions, dict.get, dict.update)

Change use of python idioms.

Not really tested, though:
- Can't get runserver.py to run on port 80
- Get error (UnixHTTPConnectionPool(host='localhost', port=None)) when I run on port 8000

These changes should not break anything, though.