Q:

Python: converting gzip file to an ordinary file

I have an ent file, compressed to .gz. I need to read it and put into Biopython parser. The problem is that the parser takes either file path or file object, but I get gzip file instead. Now I convert it like this:
file_path = 'file.ent.gz' # path to current file

file = gzip.open(file_path, 'rb') 
content = file.read() # its content

write_path = 'temp.ent' # let's write it back but as ordinary file
write_file = open(write_path, 'w')
write_file.write(content)
write_file.close()

third_file = open(write_path, 'r') #open this ordinary noncompressed file

structure = parser.get_structure('', third_file) #and finally put it into the parser

As you can see, this solution is ugly af but most importantly it takes loads of time because it writes to a drive and reads it twice, which is a problem as long as I have to do millions of such operations.
Googling didn't help me at all, docs didn't too. Is it possible to make the convertion faster?

A:

You don't need to convert anything, just feed your parser with the stream returned by gzip.open():
file_path = 'file.ent.gz' # path to current file
with gzip.open(file_path, 'rb') as finput:
    structure = parser.get_structure('', finput)

Reason: open() returns a file stream of the file content. gzip.open() returns a file stream of the uncompressed file content. Which is exactly what you need. This is a good example of the old saying: 

if it looks like a duck and walks like a duck, it is a duck

