[Python-Dev] PEP 414
Steven D'Aprano
steve at pearwood.info
Sun Feb 26 12:00:17 CET 2012
Vinay Sajip wrote:
> Serhiy Storchaka <storchaka <at> gmail.com> writes:
>
>
>> n = str
>
> Well, n to indicate that native string is required.
str indicates the native string type, because it *is* the native string type.
By definition, str = str in both Python 2.x and Python 3.x. There's no point
in aliasing it to "n".
Besides, "n" is commonly used for ints. It would be disturbing for me to read
code with n a function or type, particularly one that returns a string.
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.
--
Steven
More information about the Python-Dev
mailing list