[Python-Dev] Python in Unicode context (original) (raw)

M.-A. Lemburg mal at egenix.com
Tue Aug 3 19:35:59 CEST 2004


Martin v. Löwis wrote:

François Pinard wrote:

One thing is that a Python module should have some way to know the encoding used in its source file, maybe some kind of module._coding_'_ _next to module.file', saving the coding effectively used while compilation was going on. That would be possible to implement. Feel free to create a patch.

+1

I wonder if some other cookie, next to the coding:'_ _cookie, could not be used to declare that all strings in this module_ _only should be interpreted as Unicode by default, but without the need_ _of resorting to u' prefix all over.

This could be a starting point of another syntax debate. For example, from future import stringliteralsareunicode would be possible to implement. If PEP 244 would have been adapted, I would have proposed directive unicodestrings Other syntax forms would also be possible. Again, if you know a syntax which you like, propose a patch. Be prepared to also write a PEP defending that syntax.

+1

Things that have been proposed earlier on, extended a bit:

b'xxx' - return a buffer to hold binary data; same as buffer(s'abc')

s'abc' - (forced) 8-bit string literal in source code encoding

u'abc' - (forced) Unicode literal

'abc' - maps to s'abc' per default, can map to u'abc' based on the command line switch -U or a module switch

-- Marc-Andre Lemburg eGenix.com

Professional Python Services directly from the Source (#1, Aug 03 2004)

Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/


::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::



More information about the Python-Dev mailing list