On 26 Feb 2012, at 17:45, Antoine Pitrou wrote:

> 
> Hi,
> 
> On Sat, 25 Feb 2012 20:23:39 +0000
> Armin Ronacher <armin.ronac...@active-4.com> wrote:
>> 
>> I just uploaded PEP 414 which proposes am optional 'u' prefix for string
>> literals for Python 3.
>> 
>> You can read the PEP online: http://www.python.org/dev/peps/pep-0414/
> 
> I don't understand this sentence:
> 
>> The automatic upgrading of binary strings to unicode strings that
>> would be enabled by this proposal would make it much easier to port
>> such libraries over.
> 
> What "automatic upgrading" is that talking about?

If you use native string syntax (no prefix) then moving from Python 2 to Python 
3 automatically "upgrades" (I agree an odd choice of word) byte string literals 
to unicode string literals.

> 
>> For instance, the urllib module in Python 2 is using byte strings,
>> and the one in Python 3 is using unicode strings.
> 
> Are you talking about urllib.parse perhaps?
> 
>> By leveraging a native string, users can avoid having to adjust for
>> that.
> 
> What does "leveraging a native string" mean here?

By using native string syntax (without the unicode literals future import) then 
apis that take a binary string in Python 2 and a unicode string in Python 3 
"just work" with the same syntax. You are "leveraging" native syntax to use the 
same apis with different types across the different version of Python. 


> 
>> The following is an incomplete list of APIs and general concepts that
>> use native strings and need implicit upgrading to unicode in Python
>> 3, and which would directly benefit from this support
> 
> I'm confused. This PEP talks about unicode literals, not native string
> literals, so why would these APIs "directly benefit from this support"?

Because sometimes in your code you want to specify "native strings" and 
sometimes you want to specify Unicode strings. There is no single *syntax* that 
is compatible with both Python 2 and Python 3 that permits this. (If you use 
"u" for Unicode in Python 2 and no prefix for native strings then your code is 
Python 3 incompatible, if you use the future import so that your strings are 
unicode in both Python 2 and Python 3 then you lose the syntax for native 
strings.)

Michael


> 
> Thanks
> 
> Antoine.
> 
> 
> _______________________________________________
> 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/fuzzyman%40voidspace.org.uk
> 


--
http://www.voidspace.org.uk/


May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing 
http://www.sqlite.org/different.html





_______________________________________________
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