# testbz2.py import bz2 filename = 'some_bz2file.bz2' if __name__ == "__main__": f = bz2.BZ2File(filename, 'rb') for line in f: print(line) # testbz2file.py import bz2file filename = 'some_bz2file.bz2' if __name__ == "__main__": f = bz2file.BZ2File(filename, 'rb') for line in f: print(line)