newbie problem

Frank Buss fb at
Tue Aug 27 21:06:21 CEST 2002

"Matt Gerrans" <matt_gerrans at> wrote:

> for line in open( r'c:\temp\input.dat' ).readlines():
>    len(line.split()) > 2:
>       if line.split()[0]=='#':
>          tag=line.split()[2]
>       else:
>          print '|'.join([tag]+line.split())

Thanks, that's what I mean with "more Python-like" :-)

But I can't write "len(line.split()) > 2:". Python says "SyntaxError: 
invalid syntax" at the colon. Is there an 'if' missing, or can I add 
closure-blocks for booleans in Python like in Smalltalk?

Frank Buß, fb at,

More information about the Python-list mailing list