open is not obsolete (was Re: understanding self

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Thu Jul 8 04:00:20 CEST 2004


Jeff Shannon wrote:

> Okay, perhaps "legacy" is a better term than "obsolete".  In either
> case, it's recommended that it not be used in new code, even if there
> is no current plan to remove it.  Not that the specifics of this case
> are particularly germane to the point I was making...

As mentioned by Tony, this is not the case. From python-dev:

>> 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/)

Tim Delaney



More information about the Python-list mailing list