Newbie problem

Peter Otten __peter__ at web.de
Thu Nov 27 06:32:34 EST 2003


Angelo Secchi wrote:

> Of course I receive an error in line "data_clean.write(temp_field)"
> saying "TypeError: argument 1 must be string or read-only character
> buffer, not list". I'm a newbie and reading tutorials around I was not


Here's how to convert the list of strings into a tab-separated string:

"\t".join(temp_field)

Note that the functions in the string module are available as string
methods, for example instead of

string.replace(s, old, new) 

you'd rather write

s.replace(old, new)

A more readable way to iterate over the lines in a file is:

for temp_string in data:
    # process temp_string here

Peter




More information about the Python-list mailing list