[Python-Dev] file() or open()?

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Wed Jul 7 05:12:33 CEST 2004


Guido van Rossum wrote:

>> I have always used open() myself. does this mean we should continue
>> to use open()?
> 
> IMO, yes.  My posting was intended to draw attention to the fact that
> apparently some developers think differently.  I'm hoping to revert
> their opinions unless there's a really good reason to switch to
> file().

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.

Tim Delaney


More information about the Python-Dev mailing list