On Dec 09, 2011, at 03:18 PM, Lennart Regebro wrote:

>On Fri, Dec 9, 2011 at 04:34, Barry Warsaw <ba...@python.org> wrote:
>> Sorry, I don't understand this.  What does it mean to be "str in both
>> versions"?  And why would you want that?
>
>It means that it's a str, that is a string of bytes, in Python 2, and
>a str, that is a string of Unicode characters, in Python 3. There are
>cases where you want this, for example not all libraries will accept
>both str and Unicode under Python 2.

As Chris points out, this seems to be a use case tied to WSGI and PEP 3333.  I
guess it's an unfortunate choice for so recent a PEP, but maybe there was no
way to do better.  Still, it seems the "native string" discussion is an
indication that the PEP is introducing a binary vs. text ambiguity when
switching Python versions.  My previous "you're screwed" comment comes back to
mind. ;)

>> As for "Unicode in Python 2 and str in Python 3", unadorned strings with the
>> future import in Python >= 2.6 does that just fine.
>
>Yes, but the future import will change this for *all* strings, making
>it impossible to have a string that is a "str" in both Python 2 and
>Python 3. For that reason, the future import is not enough as a
>solution (and I suspect, one major reason why I haven't actually seen
>any one using it).

It can certainly be useful in many contexts outside of WSGI.

-Barry

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to