[Python-Dev] readd u'' literal support in 3.3?

Chris McDonough chrism at plope.com
Thu Dec 8 06:08:39 CET 2011


On the heels of Armin's blog post about the troubles of making the same
codebase run on both Python 2 and Python 3, I have a concrete
suggestion.

It would help a lot for code that straddles both Py2 and Py3 to be able
to make use of u'' literals.  It would seem to be an easy thing to
reenable (see
http://www.reddit.com/r/Python/comments/n3q7q/thoughts_on_python_3_armin_ronachers_thoughts_and/c36397t ) .  It would seem to cost very little in terms of maintenance, and not much in docs.

It would make it possible to share code like this across py2 and py3:

   a = u'foo'

Instead of (with e.g. six):

   a = u('foo')

Or:

   from __future__ import unicode_literals
   a = 'foo'

I recognize that the last option is probably the way "its meant to be
done", but in reality it's just more practical to not fail when literal
notation is more specific than strictly necessary.

- C




More information about the Python-Dev mailing list