On 2023-03-19, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: > On 20/03/23 7:07 am, Jon Ribbens wrote: >> Ah, apparently it got removed in Python 3, which is a bit odd as the >> last I heard it was added in Python 2.2 in order to achieve consistency >> with other types. > > As far as I remember, the file type came into existence > with type/class unification, and "open" became an alias > for the file type, so you could use open() and file() > interchangeably. > > With the Unicode revolution in Python 3, file handling got > a lot more complicated. Rather than a single file type, > there are now a bunch of classes that handle low-level I/O, > encoding/decoding, etc, and open() is a function again > that builds the appropriate combination of underlying > objects.
This is true, however there does exist a base class which, according to the documentation, underlies all of the different IO classes - IOBase - so it might have been neater to make 'file' be an alias for that. -- https://mail.python.org/mailman/listinfo/python-list