Dear all,
Maybe I stared on the monitor for too long, because I cannot find the
bug ...
My script transition_filter.py starts with the following lines:
import sys
for line in sys.stdin :
try :
for a,b,c,d in line.split() :
pass
except ValueError , err :
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
harold:
The output (when given the data I want to parse) is:
If you'd told us that data, and told us what version of Python you're
using, we could have reproduced the problem to look into it.
ValueError: need more than 3 values to unpack
Why does python think that I want to unpack the outcome
harold wrote:
Dear all,
Maybe I stared on the monitor for too long, because I cannot find the
bug ...
My script transition_filter.py starts with the following lines:
import sys
for line in sys.stdin :
try :
for a,b,c,d in line.split() :
pass
except
Rene Pijlman schrieb:
harold:
The output (when given the data I want to parse) is:
If you'd told us that data, and told us what version of Python you're
using, we could have reproduced the problem to look into it.
Thank you for the answers and sorry that I did not provide more
information
Thank you Gerard.
This must be the problem. Now I can get it working.
--
http://mail.python.org/mailman/listinfo/python-list
Em Sáb, 2006-04-22 às 09:21 -0700, harold escreveu:
for line in sys.stdin :
try :
for a,b,c,d in line.split() :
pass
except ValueError , err :
print line.split()
raise err
Try this:
for a, b, c, d in sys.stdin:
print a, b, c, d
--
harold:
A similar error happens in an interpreter session, when typing
for line in [1 2 3 4] :
...for a,b,c,d in line.split() :
...pass
...
Traceback (most recent call last):
File stdin, line 2, in ?
ValueError: need more than 1 value tyo unpack
maybe this might help to track down
Em Sáb, 2006-04-22 às 14:25 -0300, Felipe Almeida Lessa escreveu:
Em Sáb, 2006-04-22 às 09:21 -0700, harold escreveu:
for line in sys.stdin :
try :
for a,b,c,d in line.split() :
pass
except ValueError , err :
print line.split()
raise
harold wrote:
Thank you Gerard.
This must be the problem. Now I can get it working.
Good! I got confused thinking about it too, but I think you just had
one loop too many.
for line in sys.stdin :
try :
a,b,c,d = line.split()
not:
for line in sys.stdin :
try :
for
Thanks for all your answer!
Of course, I wanted to assign the outcome of the split(), not to
iterate
over them. Thinks are done so easy in python that, sometimes, one
does not even notice that one actually does them ;-)
Cheers,
- harold -
--
http://mail.python.org/mailman/listinfo/python-list
On 23/04/2006 2:21 AM, harold wrote:
Dear all,
Maybe I stared on the monitor for too long, because I cannot find the
bug ...
You already have your answer, but below are clues on how to solve such
problems much faster by yourself.
My script transition_filter.py starts with the following
12 matches
Mail list logo