On Tue, Dec 13, 2011 at 12:50 AM, PJ Eby
Unfortunately, AFAIR, nobody in the PEP 3333 discussions brought up either the unicode_literals import OR the strategy of using a common codebase, so 2to3 on plain code and writing new Python3 code were the only porting scenarios discussed. (Not that I'm sure it would've made a difference, as I'm not sure what we could have done differently that would still support simple Python3 code and easy 2to3 porting.)
That's not web-sig's fault though - it's only as people have been trying it and *succeeding* that we've come to realise that single code base approaches are significantly more feasible than we originally anticipated. Now, depending on whether you need to support 2.5 and earlier, we even have a reasonable answer to the native strings problem: If supporting only 2.6+, use "from __future__ import unicode_literals" and the 'str' builtin: Import at top of module: "from __future__ import unicode_literals" Text: "" Native: str("") Binary: b"" If also supporting 2.5 and earlier, use "six" (or an equivalent compatibility module): Import at top of module: "from six import u, b" Text: u("") Native: "" Binary: b("") Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia