[ANN] Python 2.4 Quick Reference available

Michael Hoffman cam.ac.uk at mh391.invalid
Sun Feb 20 09:57:14 EST 2005


François Pinard wrote:
> [Nick Coghlan]
> 
> 
>>George Sakkis wrote:
>>
>>
>>>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.
> 
> 
>>Exactly the reason the BDFL gave for preferring 'open' - it may be extended 
>>to opening other types of objects than files.
> 
> 
> So, when we *know* we are opening a file, `file' cannot be a bad choice! :-)
> Moreover, practically, most of the times, we know we are opening a file.
> 
> `open' is opened (sic!) for some future magic.  I prefer to protect my
> programs against future magic, until this magic is precisely specified.

I agree. I don't want users to be able to specify URLs instead of
filenames unless I explicitly allow it.

To be honest I doubt open will be extended in this manner. I can see
the Pythoneers adding, say, a keyword argument to open to allow a URL
instead, but just changing the current behavior would be too risky. Plus,
what happens if I have a file named "http://www.python.org/"?
-- 
Michael Hoffman



More information about the Python-list mailing list