import gzip import io with io.TextIOWrapper(io.BufferedReader(gzip.open(filename))) as file: for line in file: print line,