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.