Determine file type (binary or text)

John Machin sjmachin at lexicon.net
Wed Aug 13 19:04:55 EDT 2003


Graham Fawcett <fawcett at teksavvy.com> wrote in message news:<mailman.1060799361.14244.python-list at python.org>...
> 
> It is trivial to create a non-text file that has no NULs.
> 
>     f = open('no_zeroes.bin', 'rb')
>     for x in range(1, 256):
>         f.write(chr(x))
>     f.close()

I tried this but it didn't work. It said:

IOError: [Errno 2] No such file or directory: 'no_zeroes.bin'.

So I thought I had to be persistent but after doing it a few more times it said:

SerialIdiotError: What I tell you three times is true. 
NotLispingError:  You need 'wb' as in 'wascally wabbit'

This is very strange behaviour -- does my computer have worms?




More information about the Python-list mailing list