On Mon, Dec 2, 2013 at 5:27 AM, jade <jadec...@msn.com> wrote: > file_sigs = {'\xFF\xD8\xFF':('JPEG','jpg'), > '\x47\x49\x46':('GIF','gif')} > > file_sig = fh.read(4)
You're reading in four bytes, but your signatures are three bytes long. :) After that, all you need to do is look up file_sig in the file_sigs dictionary, and see if anything's there. Look at the Python docs for the dict type; there's an easy way to do this. ChrisA -- https://mail.python.org/mailman/listinfo/python-list