Kaydet (Commit) 81749b07 authored tarafından Guido van Rossum's avatar Guido van Rossum

Added optional second arg to what(), giving the data read from the file

(then f may be None).
üst 56a73385
......@@ -5,13 +5,19 @@
# Recognize sound headers #
#-------------------------#
def what(filename):
f = open(filename, 'r')
h = f.read(32)
for tf in tests:
res = tf(h, f)
if res:
return res
def what(filename, h=None):
if not h:
f = open(filename, 'r')
h = f.read(32)
else:
f = None
try:
for tf in tests:
res = tf(h, f)
if res:
return res
finally:
if f: f.close()
return None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment