problems when unpacking tuple ...

Tim Chase python.list at tim.thechases.com
Sat Apr 22 12:33:11 EDT 2006


>         for a,b,c,d in line.split() :
>
[snip]
> 
> The output (when given the data I want to parse) is:
> ['0.0','1','0.04','0']

You'll notice that you're not passing any parameters to 
split().  By default, it splits on whitespace, and your 
input doesn't have any whitespace in it.  Thus, you're 
actually only getting *one* (not three) elements back.  Try 
using split(",") instead.

-tkc







More information about the Python-list mailing list