Cheat sheet

Michele Simionato michele.simionato at gmail.com
Fri Dec 28 08:38:05 EST 2007


On Dec 28, 12:40 pm, "Riccardo T." <gr3yfox... at gmail.com> wrote:
> > "file" objects are generally supposed to be built with the
> > open function, not instantiated as shown.
>
> Since open() is just an alias for file(), changing the name should be
> enough, right?

It depends on the Python version:

Python 2.4.4 (#2, Oct  4 2007, 22:02:31)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> file is open
True

Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> file is open
False

Nowadays file is no more an alias for open.

 Michele Simionato



More information about the Python-list mailing list