This is my first program in Python
Remco Gerlich
scarblac at pino.selwerd.nl
Thu Jan 18 18:35:47 EST 2001
Steve Holden <sholden at holdenweb.com> wrote in comp.lang.python:
> The assignment has deliberately been designated a statement rather than an
> expression,
> The standard idiom for doing this with a while would be (untested):
>
> while 1:
> line = file.readline()
> if line == '':
> break
> first, second = line.split(':', 1)
> print first
>
> Some people don't like this. It's not going to change :-)
But in 2.1, there will be xreadlines(), readlines() without slurping the
whole file into memory, which will at least make this idiom unnecessary in
the common case of reading a file line by line :-).
--
Remco Gerlich
More information about the Python-list
mailing list