[Python-3000] Pre-PEP: Easy Text File Decoding

Paul Prescod paul at prescod.net
Sun Sep 10 20:25:07 CEST 2006

On 9/10/06, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Paul Prescod wrote:
> > The function to open a text file will tenatively be called textfile(),
> > though the function name is not an integral part of this PEP. The
> > function takes three arguments, the filename, the mode ("r", "w", "r+",
> > etc.) and the type.
> >
> > The type could be a true encoding or one of a small set of additional
> > symbolic values.
> The 'additional symbolic values' should be implemented as true encodings
> (i.e., it should be possible to look up 'site', 'guess' and 'locale' in
> the
> codecs registry, and replace them there as well).

I don't believe that these are "true" encodings because when you query a
stream for its encoding you will never find these names nor an alias for

I also agree with Guido that the right spelling for the factory function is
> to
> incorporate this into the existing open() builtin. The signature of open()
> is
> already going to change to accept an encoding argument in Py3k, and the
> special encodings proposed in the PEP are just that: special encodings
> that
> happen to take environmental information into account when deciding how to
> decode or encode data.

Yes, well I disagree that the open function should get a new argument. I
think it should either be deprecated or used to open byte streams. The
function name is a hold over from Unix/C which has no resonance with a Java,
C#, Javascript, programmer.

Plus I would like to ease the writing of code that is both valid Python 2.xand
3.x. I'd advocate the strategy that we should try to have a large enough
behavioural overlap that modules can be written to run on both. Subtle
changes in semantics make this difficult. To the extent that this is
unavoidable (e.g. behaviour of very core syntax) I guess we'll have to live
with it. But we can easily add a function called textfile() to both Python
2.x and Python 3.x and ease the transition.

 Paul Prescod
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060910/645b0c28/attachment.htm 

More information about the Python-3000 mailing list