testing the data-type of a stream

Hans-Joachim Widmaier hjwidmaier at web.de
Wed Sep 17 06:51:34 EDT 2003


David Bear <david.bear at asu.edu> wrote in message news:<m3ad94ax53.fsf at moroni.pp.asu.edu>...
> I'm writing a filter and would like to be able to do what the Linux
> 'file' command does, i.e. look at a couple of bytes to see what kind of
> data I'm dealing with, the branch based on the type. 
> [...]
> any recommendations?

You might want to take a look at 'magic'
http://www.demonseed.net/~jp/code/magic.py> Reading a few bytes from a
file and passing them on is considered trivial and left as an
exercise. ;-)

Hans-J.




More information about the Python-list mailing list