[Python-Dev] Core projects: 3to2
Terry Reedy
tjreedy at udel.edu
Thu Mar 19 09:58:27 CET 2009
Antoine Pitrou wrote:
> Terry Reedy <tjreedy <at> udel.edu> writes:
>> Some of the people who need to support both late 2.x and 3.x would
>> prefer to write 3.x code and backport. The OP of a current python-list
>> thread asked whether there was any way to write something like
>>
>> @alias('__nonzero__')
>> def __bool__(self): return True
>
> How about simply:
> __nonzero__ = __bool__
>
>> I believe my own 3.0 code will mainly also need
>> print() to print statement
>
> If this is only about supporting "late 2.x" (i.e., 2.6 and upwards), you can
> already write:
People often do not specify. I suspect some are thinking back to 2.5,
but that will change in the future.
> from __future__ import print_function
I was not aware of that. Would be ok for my current project which has
print isolated in a few modules, at least so far.
>> except e as a to 2.x version
>
> Works in 2.6.
Did not know that. Perhaps a 3 to 2.6+ guide would help.
>
>> class C() to class C(object)
Part of the reason to move to 3.0 is to not have to do that.
>
> __metaclass__ = type
>
> Now I'm not saying that all 3.0 code will work in 2.6 with such simple
> precautions, far from it!
tjr
More information about the Python-Dev
mailing list