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

"Martin v. Löwis" martin at v.loewis.de
Thu Dec 8 18:26:59 CET 2011


> 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.

You are giving these two options already:
- The former works for all Python versions. Although it may appear
  tedious to convert existing code to replace all Unicode literals
  with function calls, it would actually be possible/easy to write
  an automatic converter that does so for a complete code base,
  based on lib2to3.
- the second version is truly practical for all applications/libraries
  that only support 2.6+.

In addition, there also is another option:
- use 2to3, in some form

So you have already three solutions which are all transitional in some
sense, and you want yet another option? I fail to see why this option
is more practical than the options that are already there.

Regards,
Martin


More information about the Python-Dev mailing list