On Sat, Jul 17, 2010 at 3:34 PM, bob gailer <bgai...@gmail.com> wrote: > > You can only write strings to files. See 6.9 in the documentation: > file.write(str) Write a string to the file b mode only affects how line ends > are handled. See 2. Built-in Functions: > > The default is to use text mode, which may convert '\n' characters to a > platform-specific representation on writing and back on reading. Thus, when > opening a binary file, you should append 'b' to the mode value to open the > file in binary mode, which will improve portability. (Appending 'b' is > useful even on systems that don’t treat binary and text files differently, > where it serves as documentation.) >
me and Bob are in tune, it seems, I was composing the same message. Would like to add that in python 3.x the 'b' does make a difference, since read and write will use the 'bytes' type. Also, if you don't mind a binary file, I would also like to suggest the following non-python solution: $ dd if=/dev/urandom of=rand_numbers.txt count=100MB and adjust the count argument to your liking. Hugo _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor