Combining Lists and Tupels

Terry Reedy tjreedy at udel.edu
Thu May 22 15:11:20 EDT 2003


"Batista, Facundo" <FBatista at uniFON.com.ar> wrote in message
news:mailman.1053610184.9432.python-list at python.org...
> You're not thinking in a Python way.
>
> f = file("test.csv")
> list = []
better, mylist = []

> for currentline in f:
>  data = currentline.split()
>  address = (data[2], data[3], data[4])
>  list.append((data[0], data[1], address))
better, mylist.append....


> Pay attention to the double (( and )) in the append.
but don't copy this imitation of (OP's) use of builtin name 'list' as
a variable.

Otherwise, this is *much* better, given reasonable assumptions of what
the OP wanted.

Terry J. Reedy






More information about the Python-list mailing list