problems when unpacking tuple ...

Felipe Almeida Lessa felipe.lessa at gmail.com
Sat Apr 22 13:41:07 EDT 2006


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 err 
> 
> Try this:
> 
> for a, b, c, d in sys.stdin:
>      print a, b, c, d
> 

Forget that. It was stupid. You should try this instead:

for line in sys.stdin:
    a, b, c, d = line.split()

-- 
Felipe.




More information about the Python-list mailing list