[Python-Dev] str object going in Py3K

Alex Martelli aleaxit at gmail.com
Thu Feb 16 06:59:55 CET 2006


On Feb 15, 2006, at 9:51 AM, Barry Warsaw wrote:

> On Wed, 2006-02-15 at 09:17 -0800, Guido van Rossum wrote:
>
>> Regarding open vs. opentext, I'm still not sure. I don't want to
>> generalize from the openbytes precedent to openstr or openunicode
>> (especially since the former is wrong in 2.x and the latter is wrong
>> in 3.0). I'm tempting to hold out for open() since it's most
>> compatible.
>
> If we go with two functions, I'd much rather hang them off of the file
> type object then add two new builtins.  I really do think file.bytes()
> and file.text() (a.k.a. open.bytes() and open.text()) is better than
> opentext() or openbytes().

I agree, or, MAL's idea of bytes.open() and unicode.open() is also  
good.  My fondest dream is that we do NOT have an 'open' builtin  
which has proven to be very error-prone when used in Windows by  
newbies (as evidenced by beginner errors as seen on c.l.py, the  
python-help lists, and other venues) -- defaulting 'open' to text is  
errorprone, defaulting it to binary doesn't seem the greatest idea  
either, principle "when in doubt, resist the temptation to guess"  
strongly suggests not having 'open' as a built-in at all.  (And  
namemangling into openthis and openthat seems less Pythonic to me  
than exploiting namespaces by making structured names, either  
this.open and that.open or open.this and open.that).  IOW, I entirely  
agree with Barry and Marc Andre.


Alex




More information about the Python-Dev mailing list