[Python-3000] Proposed new language for newline parameter to TextIOBase
Adam Olsen
rhamph at gmail.com
Wed Aug 15 19:39:34 CEST 2007
On 8/15/07, Christian Heimes <lists at cheimes.de> wrote:
> Brett Cannon wrote:
> > I like the options, but I would swap the meaning of None and the empty
> > string. My reasoning for this is that for option 3 it says to me
> > "here is a string representing EOL, and make it \n". So I would think
> > of the empty string as, "I don't know what EOL is, but I want it
> > translated to \n". Then None means, "I don't want any translation
> > done" by the fact that the argument is not a string. In other words,
> > the existence of a string argument means you want EOL translated to
> > \n, and the specific value of 'newline' specifying how to determine
> > what EOL is.
>
> I like to propose some constants which should be used instead of the
> strings:
>
> MAC = '\r'
> UNIX = '\n'
> WINDOWS = '\r\n'
> UNIVERSAL = ''
> NOTRANSLATE = None
>
> I think that open(filename, newline=io.UNIVERSAL) or open(filename,
> newline=io.WINDOWS) is much more readable than open(filename,
> newline=''). Besides I always forget if Windows is '\r\n' or '\n\r'. *g*
I agree, but please make the constants opaque. I don't want to see a
random mix of constants and non-constants. Plus, opaque constants
could be self-documenting.
--
Adam Olsen, aka Rhamphoryncus
More information about the Python-3000
mailing list