Re: [Tutor] Error writing to file...

2009-12-26 Thread ALAN GAULD
> The docs say > > "write( str) - Write a string to the file." > > Only a string. Regardless of mode. > Mode mostly affects interpretation of line ends. Thats true of course, you need to encode the binary data with struct to write it as binary. Alan G.

Re: [Tutor] Error writing to file...

2009-12-25 Thread bob gailer
The docs say "write( str) - Write a string to the file." Only a string. Regardless of mode. Mode mostly affects interpretation of line ends. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org To unsubscribe or change s

Re: [Tutor] Error writing to file...

2009-12-25 Thread Alan Gauld
"Ken G." wrote the program run fine. Do I need to convert a numeric random number to a string number? You need to convert your data to a string if you use a text file, which is the default. If you open the file with 'wb' you can write any kind of data to it, but you will have to decode it w

Re: [Tutor] Error writing to file...

2009-12-25 Thread David
On 12/25/09 15:00, Ken G. wrote: In writing the following program in creating random numbers and writing them to the file, I get an type error in writing to file. I have tried number = random(10,99), number = randint(10.99), and number = random.random(10,00) and still get various errors of writin

Re: [Tutor] Error writing to file...

2009-12-25 Thread GilJohnson
Ken G. insightbb.com> writes: > [...] > Do I need to convert a numeric random number to a string number? > [...] Yes, as long as you open the file as "w" you need to use "repr()" [repr(int)]. If you want to save the integer, you need to open a file as "wb", write binary. Check your documentation

Re: [Tutor] Error writing to file...(SOLVED)

2009-12-25 Thread Ken G.
Thanks! So a file will only take a numeric as a string? Lesson learned. Again, thanks. Ken Amit Sethi wrote: It is as the Error says a type error , the function takes a string and u are passing an int if you put file.write(str(number)) you will not get error .. __

Re: [Tutor] Error writing to file...

2009-12-25 Thread Ken G.
Thinking it was a reply to me on Python Tutor, I translated the following into English for the board. Ken � DIAGORN wrote: Bonjour, Je suis absente jusqu'au 03/01/10 inclus. En cas d'urgence Soprane, contacter notre adresse générique projet.sopr...@teamlog.com. Joyeuses fêtes de fin d'année.

[Tutor] Error writing to file...

2009-12-25 Thread Ken G.
In writing the following program in creating random numbers and writing them to the file, I get an type error in writing to file. I have tried number = random(10,99), number = randint(10.99), and number = random.random(10,00) and still get various errors of writing to file. If I were to REM o