Python 3

Martin Pool mbp at canonical.com
Wed Jun 23 07:11:14 BST 2010


On 23 June 2010 15:52, Russel Winder <russel at russel.org.uk> wrote:
> Robert,

The message Russel is responding to here is Robert's proposal that we
make certain changes (shown by the arrows) to our coding style so that
we can have a single codebase that works on 2.4  .. 3.1.

>
> On Wed, 2010-06-23 at 09:47 +1200, Robert Collins wrote:
> [ . . . ]
>> print foo, bar -> print("%s %s" % (foo, bar))
> [ . . . ]
>
> Just to protect against creation of misinformation:
>
>
> print foo , bar  ->  print ( foo , bar )

Those two statements do different things in 2.x so no, the second is
not ok as a coding guideline for a single codebase.

>
> Also the "%s" and % operator are deprecated in Python 3, so:
>
> print ( "%s %s" % ( foo , bar ) ) -> print ( "{} {}".format ( foo ,
> bar ) )
>

There's no .format in python2.4.

>
>> except Foo, e:
>> ->
>> except Foo:
>>     e = sys.exc_info()[1]
>
> Why?
>
> except Foo , e : ->  except Foo as e :

What Robert proposes will work for a single codebase but there is no
"as e" on 2.4.

One of the major points of this thread and previous ones is that we
are not prepared to give up 2.4 support yet.  I do realize that it
would be easier to support 3.x if we dropped 2.4 but we're not going
there yet.

-- 
Martin



More information about the bazaar mailing list