On Tue, May 5, 2009 at 5:41 AM, spir <[email protected]> wrote:

> Le Tue, 5 May 2009 00:41:39 +0100,
> "Alan Gauld" <[email protected]> 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!
> >
> > A pity, there are cases where I found file() more intuitive than
> > open and vice versa so liked having both available. The fact that it
> > looked like creating an instance of a class seemed to fit well
> > in OO code.
>
> Same for me. It makes files an exception in the python OO system.
> Conversely, I have always considered open(), rather than file(), a flaw.
> (But there are numerous things on which I have a different point of view
> than the majority of pythonistas ;-)
>

Well, when you consider that it's really, underneath everything(way down in
the assembly code), a pointer to a location on the hard disk/memory, open
does make a little more sense. Of course, conversely there are also (like
Alan mentioned) cases where file just makes more sense when you're looking
at/writing the code, even if the concept may not technically be correct.
Still, I think that's part of OO programming - obscuring some of the
underlying ideas in favor of clarity of purpose.

For those of us who may still find a need/desire to use file(), I'm sure
file = open still works in python3 ( of course that's not making one
preferably obvious right way of doing things )

-Wayne

-- 
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn’t. - Primo Levi
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to