[Tutor] writing binary files

alan.gauld@bt.com alan.gauld@bt.com
Fri, 28 Jul 2000 11:06:18 +0100

How do I write binary data to a file?
I can open a file with 'wb' as mode but if I do:

b = open('bin.dat','wb')
for i in range(50): b.write(i)

I get an error.

I can read binary data using the size parameter 
to f.read() but I can't see how to write the stuff. 
Any ideas? Do I need to use the low level open() 
in the os module?

Alan G.