Because file can't use in python 3.
In python 2, we judge a file type can do this:
with open("xxx.txt") as f:
if isinstance(f, file):
print("ok!")
In python 3, we can do this:
import io
with open("xxx.txt") as f:
if isinstance(f, io.IOBase)
print("ok!")
But the second code can't work in python 2.
So, is there a way to judge a file type both work in python 2 and python 3.