Allow open file as parameter (must be seekable) (Jack)

This commit is contained in:
Guido van Rossum 1997-10-08 15:22:32 +00:00
parent 845037018d
commit 45ac47c0b2
1 changed files with 10 additions and 4 deletions

View File

@ -2,13 +2,19 @@
#-------------------------#
# Recognize sound headers #
# Recognize image headers #
#-------------------------#
def what(filename, h=None):
def what(file, h=None):
if h is None:
f = open(filename, 'r')
h = f.read(32)
if type(file) == type(''):
f = open(file, 'rb')
h = f.read(32)
else:
location = file.tell()
h = file.read(32)
file.seek(location)
f = None
else:
f = None
try: