Range Operation pre-PEP

Alex Martelli aleaxit at yahoo.com
Wed May 16 07:09:51 EDT 2001


"Magnus Lie Hetland" <mlh at idi.ntnu.no> wrote in message
news:9ds9ed$4ga$1 at tyfon.itea.ntnu.no...
    ...
>   for line in sys.stdin:
>       ...
>
> seems like a very Pythonesque way of spelling the
> abhorrent
>
>   while (<>) {
>      ...
>   }

Except it won't do, because the latter depends on
sys.argv and the former doesn't.  The Python
spelling for the "abhorrent Perl idiom" is:

    for line in fileinput.input():
        ...

and this DOES have the same semantics as said idiom.


Alex






More information about the Python-list mailing list