David M. Cooke wrote:

"""
The file() constructor is new in Python 2.2 and is an alias for
open(). Both spellings are equivalent. The intent is for open() to
continue to be preferred for use as a factory function which returns a
new file object. The spelling, file is more suited to type testing
(for example, writing "isinstance(f, file)").
"""

There was a discussion on python-dev (earlier this year IIRC) where someone started changing the stdlib to use file() instead of open() and the BDFL clarified what he originally wanted with file().

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.

It's one of the few places where my personal style disagrees with
the "official" Python style but I just like file() so much better ;)
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to