[Tutor] Re: Newbie - Outputting List to a File

Andrei project5 at redrival.net
Tue Oct 14 15:27:27 EDT 2003


Matt Hehman wrote:
<snip>
>  I was wondering if there was a way to save the list
> of primes generated to an output file so that I could
> just retrieve it and use it for the next number I
> tested.  I tried the .write command and received the
> error message:

It's called a method (function inside a class).

> TypeError: argument 1 must be string or read-only
> character buffer, not list

Use the str() function to convert a list (or anything else for that matter) to a 
string, like this:

somefile.write(str(somelist))

-- 
Yours,

Andrei

=====
Mail address in header catches spam. Real contact info (decode with rot13):
cebwrpg5 at bcrenznvy.pbz. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur 
yvfg, fb gurer'f ab arrq gb PP.





More information about the Tutor mailing list