[Python-3000] Python 3.0 Porting Strategies
Eric Smith
eric+python-dev at trueblade.com
Fri Mar 28 01:26:30 CET 2008
Greg Ewing wrote:
> Charles Merriam wrote:
>> How can I write the greatest common denominator of this code:
>>
>> print "Hello World!" # yes, that needs to be Unicode.
>
> Something like
>
> from __future__ import unicode_literals
> from py3k_compat import Print
>
> Print("Hello World!") # yes, that indeed is Unicode.
>
> given suitable implementations of py3k_compat for
> each environment.
>
Am I missing something here? What's wrong with:
$ ./python.exe
Python 2.6a1+ (trunk:61978, Mar 27 2008, 12:48:39)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import unicode_literals
>>> from __future__ import print_function
>>> print('hello, world')
hello, world
>>> type('hello, world')
<type 'unicode'>
>>>
The only problem I see is that the __future__ import of unicode_literals
doesn't work in 3.0 yet. I'll look into fixing that.
Eric.
More information about the Python-3000
mailing list