[ANN] Python 2.4 Quick Reference available

George Sakkis gsakkis at rutgers.edu
Sat Feb 19 21:23:39 EST 2005


"David M. Cooke" <cookedm+news at physics.mcmaster.ca> wrote in message
news:qnkll9kv09y.fsf at arbutus.physics.mcmaster.ca...
> "Pete Havens" <peter.havens at gmail.com> writes:
>
> > The is awesome! Thanks. I did notice one thing while reading it. In the
> > "File Object" section, it states:
> >
> > "Created with built-in functions open() [preferred] or its alias
> > file()."
> >
> > ...this seems to be the opposite of the Python documentation:
> >
> > "The file() constructor is new in Python 2.2. The previous spelling,
> > open(), is retained for compatibility, and is an alias for file()."
>
> Except if you look at the current development docs
> (http://www.python.org/dev/doc/devel/lib/built-in-funcs.html) it says
>
> """
> The file() constructor is new in Python 2.2 and is an alias for
> open(). Both spellings are equivalent. The intent is for open() to
> continue to be preferred for use as a factory function which returns a
> new file object. The spelling, file is more suited to type testing
> (for example, writing "isinstance(f, file)").
> """
>
> ... which more accurately reflects what I believe the consensus is
> about the usage of open vs. file.
>
> -- 
> |>|\/|<
> /--------------------------------------------------------------------------\
> |David M. Cooke
> |cookedm(at)physics(dot)mcmaster(dot)ca


Still the word "open" sounds too general if the meaning is "open a file-like object"; OTOH this
could be a good thing if in some future version "open('http://www.python.org')" was e.g. an alias to
urllib2.urlopen.

George







More information about the Python-list mailing list