On Sat, Jul 17, 2010 at 2:01 PM, Richard D. Moores <rdmoo...@gmail.com> wrote: > That's the goal of the latest version of my script at > <http://tutoree7.pastebin.com/5XYaaNfp>. The best I've been able to do > so far is a file with 800 million digits. > > But it seems the writing of 800 million digits is the limit for the > amount of memory my laptop has (4 GB). So my question is, how can I do > this differently? I'm pretty brand new to opening and writing files. > Here, I can't write many shorter lines, because the end result I seek > is one long string. But am I correct? >
You are not, and it would have been quite trivial to verify that: $ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> f = open("test.txt", 'w') >>> f.write('hello') >>> f.write('world\n') >>> f.close() >>> $ cat test.txt helloworld $ As you can see, two subsequent writes will end up on a single line. If you want a newline character, you have to specify it yourself, like I did after the second write. So you can generate your large number in small pieces, no problem at all. Hugo _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor