[Tutor] quick question to open(filename, 'r') vs. file(filename, 'r')
Mark Tolonen
metolone+gmane at gmail.com
Tue May 5 16:20:35 CEST 2009
"W W" <srilyk at gmail.com> wrote in message
news:333efb450905050408m48246dd8wc90b94880898e3ca at mail.gmail.com...
On Tue, May 5, 2009 at 5:41 AM, spir <denis.spir at free.fr> wrote:
> Le Tue, 5 May 2009 00:41:39 +0100,
> "Alan Gauld" <alan.gauld at btinternet.com> s'exprima ainsi:
>
> > > Backwards compatibility. The file type was introduced in python 2.2,
> > > before which there was open.
> >
> > And file has been removed again in Python v3....
> > In fact open is now an alias for io.open and no longer simply returns
> > a file object - in fact the file type itself is gone too!
I, for one, am glad it is gone again. It took awhile to train myself not to
write:
file = open('filename.txt')
and incorrectly shadow the built-in. It's just the most natural name for
the variable :^)
-Mark
More information about the Tutor
mailing list