[ANN] Python 2.4 Quick Reference available

Peter Hansen peter at engcorp.com
Sun Feb 20 18:01:56 EST 2005


Michael Hoffman wrote:
> That said, I still use file() instead of open(). I think that:
> 
> for line in file("mytext.txt"):
> 
> makes a lot more sense than:
> 
> for line in open("mytext.txt"):
> 
> I guess it's because the first option sounds a lot more like English.

Call me a space-waster (or a "waste of space" ;-)  but I
still prefer this one to either of the above:

file = open('mytext.txt')
for line in file:
    ...


-Peter



More information about the Python-list mailing list