To read contents of a file:
data = open(filename, \"r\").read()
The open file immediately stops being referenced anywhere, so the file obje
Just for the record: This is only slightly longer, and closes the file immediately:
from __future__ import with_statement with open(filename, "r") as f: data = f.read()