[Python-3000] Enough with the u"string" already!
Christian Heimes
lists at cheimes.de
Mon Mar 24 23:06:34 CET 2008
Benjamin Peterson schrieb:
> On Mon, Mar 24, 2008 at 2:38 PM, Christian Heimes <lists at cheimes.de> wrote:
>
>> Guido van Rossum schrieb:
>>> Thanks; the __future__ import in 2.6 sounds great.
>> I'm working on it. However it's not as easy as we first thought.
>
> What's the problem?
Since 2.4 Python uses the AST tree to access the future flags. But the
string unicode literals require the information before the AST tree is
created.
I solved the problem using some code from Python 2.3. A patch is
available at
bzr+ssh://pythonbzr@code.python.org/python/users/christian.heimes/unicode_string_literals
It's very rough, hacky but it works. :]
from __future__ import unicode_string_literals, print_function
print(type("test"), type(u"test"), type(b"test"))
<type 'unicode'> <type 'unicode'> <type 'str'>
It doesn't work in the interactive shell yet.
Christian
More information about the Python-3000
mailing list