"Emile van Sebille" <em...@fenx.com> wrote in message news:gtnrtf$pi...@ger.gmane.org...
On 5/4/2009 2:50 PM bob gailer said...
PDavid wrote:
Dear list,

in different books I come across different syntax for dealing with
files. It seems that open(filename, 'r') and file(filename, 'r') are
used interchangeably, and I wonder what this is all about. Is there a
reason why Python allows such ambiguity here?

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.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/l2p/

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to