[Python-3000] Python 3.0 Porting Strategies

Nick Coghlan ncoghlan at gmail.com
Thu Mar 27 09:23:21 CET 2008


Charles Merriam wrote:
> On Wed, Mar 26, 2008 at 9:33 PM, Talin <talin at acm.org> wrote:
> ...
>>  For new code, however, there is an alternative strategy that doesn't
>>  involve 2to3 at all, which is to write code in the "greatest common
>>  subset" of 2.6 and 3.0.
>>
>>  As Lennart Regbro pointed out earlier, this common subset is actually
>>  quite large (larger than Guido originally intended, I think), and you
>>  can write some fairly substantial applications in it.
> 
> Ok, I'll bite.  How can I write the greatest common denominator of this code:
> print "Hello World!"  # yes, that needs to be Unicode.

# This code will run on both 2.6 and 3.0
# And the string will be Unicode in both
from __future__ import unicode_literals
print "Hello World!"

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list