[Python-Dev] file() or open()?
Guido van Rossum
guido at python.org
Wed Jul 7 06:04:40 CEST 2004
> Then should the following line in the reference be changed?
>
> "The file() constructor is new in Python 2.2. The previous spelling,
> open(), is retained for compatibility, and is an alias for file()."
>
> That *strongly* suggests that the preferred spelling is file(), and
> that open() shouldn't be used for new code.
Oops, yes. I didn't write that, and it doesn't convey my feelings
about file() vs. open(). Here's a suggestion for better words:
"The file class is new in Python 2.2. It represents the type (class)
of objects returned by the built-in open() function. Its constructor
is an alias for open(), but for future and backwards compatibility,
open() remains preferred."
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list