[Web-SIG] Unicode in Python 3
g.brandl at gmx.net
Sat Sep 19 15:26:39 CEST 2009
René Dudfield schrieb:
>>> Here is a snippet from the compat.py we used to port pygame to support
>>> python2.3 through 3.1
>> How is that related?
> Rather than using a 2to3 tool - which then makes you have two versions
> of your code, making the code work in python 2.x and 3.x. 2to3
> outputs python2.x incompatible code - when it doesn't have to.
Sorry, but I think you do not express the intent of 2to3 correctly here.
It is not meant to provide a one-time conversion, so that you then
have to maintain two codebases, it is meant to be run over your 2.x code
every time you want to distribute a version for Python 3, or even
transparently in the distutils build process. This of course means that
the 2.x code needs to be written with 3.x and the conversion in mind.
Writing code that runs unchanged on 2.x (where x < 6) and 3.x may seem
nice, but forces you to do unnecessary workarounds, e.g. in exception
>>> Arguments against using bytes (and using unicode instead).
>>> So I'm -1 on using b'' all over the place since it's not in both
>>> versions of python, and makes it impossible for code bases to share
>>> the same code for multiple versions of python.
>> That would not matter much because the high-level applications never see
>> what's under the hood. Besides web2py all frameworks and libraries I
>> know about are using unicode internally anyways.
> It would mean code bases need to support b'' - which is not compatible
> with python2.
b'' is supported as of Python 2.6.
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.
More information about the Web-SIG