[Python-Dev] PEP 414
Nick Coghlan
ncoghlan at gmail.com
Sun Feb 26 12:20:16 CET 2012
On Sun, Feb 26, 2012 at 9:00 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> I think your suggestion is not well explained. You suggested a function n,
> expected to take a string literal. The example you gave earlier was:
>
> n('xxx')
>
> But it seems to me that this is a no-op, because 'xxx' is already the native
> string type. In Python 2, it gives a str (byte-string), which the n()
> function converts to a byte-string. In Python 3, it gives a str
> (unicode-string), which the n() function converts to a unicode-string.
Vinay's suggestion was that it be used in conjunction with the "from
__future__ import unicode_literals" import, so that you could write:
b"" # Binary data
"" # Text (unicode) data
str("") # Native string type
It reduces the problem (compared to omitting the import and using a
u() function), but it's still ugly and still involves the "action at a
distance" of the unicode literals import.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev
mailing list