Python 3 (was Re: Anelok: next round of case parts 1/2: fixing issues)

Bas Wijnen wijnen at debian.org
Mon Jan 26 08:04:54 UTC 2015


On Sun, Jan 25, 2015 at 02:59:38PM +0100, Paul Boddie wrote:
> On Sunday 25. January 2015 10.07.34 Elena ``of Valhalla'' wrote:
> > On 2015-01-25 at 02:56:43 -0300, Werner Almesberger wrote:
> > > Bas Wijnen wrote:
> > > > If you want to be future-proof, you probably want to use python3, in
> > > > which 3/2 == 1.5 (and 4/2 == 2.0, not 2); you have to specify integer
> > > > division explicitly as 3//2 there.
> > > 
> > > Oooh, that explains everything. That's a pretty fundamental change to
> > > make in a widely deployed language.
> > > [...]
> > > Hmm, just saw that they removed (converted) the print statement in
> > > version 3. And I thought the gcc folks were reckless ;-)
> 
> Where have you been, Werner?! Python 3.0 came out in 2008. :-)

To get you up to date, although probably irrelevant for what you're
doing: the main difference between python 2 and python 3 IME is that
they changed the meaning for str from a byte string to a character
string, and added an explicit type bytes for character strings.  All
encoding and decoding (to and from utf-8 or if you're unlucky (or evil),
other encodings) must be explicit.

And yes, print has become a real function, which means it is no longer a
reserved word.  If you always print only a single string, and use
parentheses, it works in both versions.

> > You can use just the new division behaviour by importing ``division``
> > from __future__, or you can import all of the four modules and
> > try to keep the code running under both versions.

Or indeed, as you write, you can use // and explicit floats to be
explicit.

> I'm not a fan of what they did with Python 3, even if it could be said to be a 
> better language.

I like most of the changes.  The str change is invasive, but the result
is a lot better.  I've also been looking for "yield from" for years, and
just recently found that it exists in python 3.  (Obviously, I wasn't
looking for that specific syntax, but for what it does.)

> On the topic of CAD and modelling, I believe the Blender 
> project experienced a degree of inconvenience after being persuaded to be 
> Python 3 early adopters.

I agree, but on the other hand I think it was a good choice.  Everyone
will eventually be using Python 3, and the Blender artists will not need
to relearn things.

> And the whole business has just created confusion and 
> fragmentation (and a degree of hostility towards anyone who doesn't 
> unconditionally advocate Python 3 adoption).

Oh, I didn't notice that; that's not nice.  The only reason I delayed
using Python 3 is that Gtk2 isn't supported on it.  Gtk3 is, but that is
incredibly slow on my machine, so it isn't always an option.  I'm
thinking of moving to a different widget set anyway.  Does anyone here
have suggestions?

> Having now acquainted Werner with Python 3, perhaps we shouldn't mention the 
> latest core developer push for type annotations in Python. :-)

Too late. :-P  I have no idea what you're talking about though.  That's
probably because I'm not really a part of the Python world, even though
I use it a lot.

Thanks,
Bas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.en.qi-hardware.com/pipermail/discussion/attachments/20150126/473e55e3/attachment.sig>


More information about the discussion mailing list


interactive