Mystery Python Theater 3K

PYPTUG Presents

a

Francois Dion Production

Short Version

Python 2.x is legacy, Python 3.x is the present and future of the language

Tell me more

  • More consistent (see: Is Python 3 a better language to teach beginning programmers?)
  • strings are Unicode by default
  • clean Unicode/bytes separation
  • exception chaining
  • function annotations
  • syntax for keyword-only arguments
  • extended tuple unpacking
  • non-local variable declarations
  • and good 2.x practices enforced (print, format, new style classes, lazy iterators, native when available)

Next Step?

Follow the arrow...

But don't forget to come back!

2to3

Once you have confirmed that the packages you are using do have a Python 3 version (or some equivalent), it is time to do a quick check:

$ python -3 script.py

 

Review the warnings to see what is non trivial

 

No warning? Run 2to3!

$ 2to3 -w .

$ 2to3 -w -d .

Case #1

MMA

Case #2

Case #3

Providing 2 and 3

One thing that is still important at this point in time, is to provide support for both Python 2 and 3. But it doesn't mean you have to support older versions than 2.6 and 3.3. That will make your life simpler.

 

If you are providing a package with setup.py, make sure your setup.py is set up to install the correct code. See python3porting.com for more details.

Reality Check

Testing is important

Even if you are not going to have a Python 2 and Python 3 version, set up virtualenv, and some way to automate your tests.

 

One easy to use combo is Jenkins with Shining Panda plugin (uses virtualenv and tox). Makes it easy to use multibuild against various python interpreters, version of modules and to do coverage, code check (pep8) and automated documentation (along with sphinx).

Show Me

Python 3 availability

It's not available widely enough...

Really?

Phones (even mine), niche OSes (OI Hipster anyone?) and even...

Python 3 in Near Space

Flight #NSC01

Wall of Superpowers

Mystery Python Theater 3K

By Francois Dion

Mystery Python Theater 3K

  • 4,460