I was looking through the source code for the imghdr
module, which is part of the python standard library (I use 2.7). The structure is pretty simple—a what
function that iterates over a list of functions with names like test_filetype
, and if the passed in file matches any of the tests, it returns the string for that filetype.
All of the test_filetype
functions take two arguments, h
and f
. h
is a string with the contents of f.read(32)
, and f
is the open file object. None of the test_filetype
functions actually use f
for anything.
Why would the set of test_filetype
functions all take an argument that is never used?