what's going on here?

Schüle Daniel uval at rz.uni-karlsruhe.de
Thu Mar 16 12:41:08 EST 2006


[...]

> So finally here's my question: If you are using data.append(), doesn't 
> that just put all the numbers into one long list? 

no, append appends
extend does what you think

How are the tuples
> still being created in this case so that the list comprehensions still 
> work? It seems like there is no longer any 'row' to refer to in data.

why not to fire interpreter to see what happens

 >>> line1 = "1 2 3 4"
 >>> line2 = "5 6 7 8"
 >>> lst = []
 >>> lst.append(map(float, line1.split()))
 >>> lst
[[1.0, 2.0, 3.0, 4.0]]
 >>> lst.append(map(float, line2.split()))
 >>> lst
[[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]
 >>>


hth, Daniel




More information about the Python-list mailing list