Re: Determine file type (binary or text)
John Machin wrote:
[color=blue]
>Graham Fawcett <fawcett@teksav vy.com> wrote in message news:<mailman.1 060799361.14244 .python-list@python.org >...
>
>[color=green]
>>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()
>>
>>[/color]
>
>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:
>
>SerialIdiotErr or: What I tell you three times is true.
>NotLispingErro r: You need 'wb' as in 'wascally wabbit'
>
>This is very strange behaviour -- does my computer have worms?
>
>[/color]
No, but my brain does. Glad you caught my typo.
However, it looks like your computer definitely has an AttitudeError!
-- Graham
John Machin wrote:
[color=blue]
>Graham Fawcett <fawcett@teksav vy.com> wrote in message news:<mailman.1 060799361.14244 .python-list@python.org >...
>
>[color=green]
>>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()
>>
>>[/color]
>
>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:
>
>SerialIdiotErr or: What I tell you three times is true.
>NotLispingErro r: You need 'wb' as in 'wascally wabbit'
>
>This is very strange behaviour -- does my computer have worms?
>
>[/color]
No, but my brain does. Glad you caught my typo.
However, it looks like your computer definitely has an AttitudeError!
-- Graham
Comment