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

Guido van Rossum guido at python.org
Wed Jul 7 17:51:48 CEST 2004

> I presumed file() was preferred to open() for the simple reason that
> it says more explicitly what you are doing. You are constructing a
> file object. "open()" doesn't say whether you are opening a file or
> socket or window or folder or ...
> open made sense in a Unix world where "everything was a file"
> (except that even then it wasn't really) but it is a poor name for
> the file opening function in a 21st century language.

Maybe you'll change your mind when open() can return other objects
besides files.  In the mean time, let's use the compatibility
argument.  Changing things just because a new century has started
sounds like a fad to me -- IOW the argument "it's the modern thing to
do" usually doesn't convince me.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list