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 follow
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
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 a
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()
> >
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 "", line 2, in ?
>ValueError: need more than 1 value tyo unpack
>
>maybe this might help to
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
-
Thank you Gerard.
This must be the problem. Now I can get it working.
--
http://mail.python.org/mailman/listinfo/python-list
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
inform
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
>
>
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 outcom
> 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'
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 :
pri
12 matches
Mail list logo