In article <[EMAIL PROTECTED]>, "max(01)*" <[EMAIL PROTECTED]> wrote:
> i have some problems understanding following behaviour. > > consider this: > $ cat file_input_3.pl > #!/usr/bin/perl > > open MIAPIPE, "una_pipe"; > > while ($riga = <MIAPIPE>) ... > $ cat file_input_3.py > #!/usr/bin/python > > import sys > > MIAPIPE = open("una_pipe", "r") > > for riga in MIAPIPE: ... > BUT if i try to do the same with the python code, something different > happens: i have to type ALL the lines on console #2 and complete the cat > command (ctrl-d) before seeing the lines echoed on console #1. Seems to me something like this came up here not long ago. It turns out that for line in file: doesn't do the same thing as Perl's while ($line = <file>) If you use file.readline() instead (in a loop, of course, I think you'll get the data one line at a time, but "in file" apparently reads the whole file first. That's what I vaguely remember, I don't use it myself. Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list