[FM Discuss] Fwd: [Edu-sig] What version of Python to teach ....

Edward Cherlin echerlin at gmail.com
Sun Apr 19 13:30:23 PDT 2009


I think we are in a unique position to take advantage of this
opportunity. It is clear that documentation of converting Python 2.x
to 3.0 will be needed. Here we have a ready-made collection of
teaching examples that we can analyze. (Also, we could do a
conventional Python book with all Python 3.0 code. Does O'Reilly have
one in need of a super-fast update?)

Converting to Python 3.0

Why Python 3.0 Breaks Compatibility
How Python 3.0 Breaks Compatibility
The 2to3 Conversion Tool
What Just Works
What Almost Works (But You Have to Decide How It Should Work)
What Does Not Convert, and What To Do
Refactoring for Python 3.0
After conversion (Brooks's Law: Software you can distribute takes
three times as much work as software you can use yourself.)

How many Pythonistas do we have in this conversation? I can ask the
Python community in general, and Guido in particular, about the
issues.

---------- Forwarded message ----------
From: Edward Cherlin <echerlin at gmail.com>
Date: Sun, Apr 19, 2009 at 12:49 PM
Subject: Re: [Edu-sig] What version of Python to teach ....
To: edu-sig at python.org


On Sun, Apr 19, 2009 at 12:07 PM, Laura Creighton <lac at openend.se> wrote:
>
> One note:
> It is very important to teach your students how to read code.  I think that
> this is even more important that teaching them how to write code -- not
> only will they spend more time reading code than writing code in their
> lives, but it is through reading other people's code that you can learn
> any technique for writing code.  (Well, that, and a whole lot of practice,
> but a certain amount of reading of code every day can cut down on the
> number of things that you have to learn by doing.)
>
> There isn't a lot of Python 3.0 code out there to read.  So even if you
> are only teaching your students how to write 3.0, you will still have to
> teach them how to read 2.x.

I wonder how much of that is needed. You do need to teach them how to
convert 2.x code to 3.0,
but in many cases this is not too burdensome.

http://www.comp.leeds.ac.uk/nde/papers/teachpy3.html

The Python 3.0 distribution comes with a refactoring tool called 2to3,
intended to assist with the translation of Python 2.x code to Python
3.0. The tool operates on stdin, individual files or an entire
directory tree. It writes a unified diff patch for each .py file to
stdout, and a summary of which files needed changes to stderr. With
the -w command line option, it will create a back-up of each file and
then apply the patch to the file.

An an experiment, we tried running the 2to3 tool provided in the third
alpha release of Python 3.0 on the collection of example programs used
in our first-year programming lectures [10], using the -w option to
apply the patches. The tool took 47.2 seconds to process 147 .py files
[11] and changed 77 of them (52% of the total).

In 80% of cases, the changes involved console I/O only and no manual
intervention was required to produce satisfactory code. In 5% of
cases, 2to3 produced code that ran correctly but was redundant in some
way.

(A conversion example follows).

It would be interesting to go through this collection of examples
used in teaching 2.x, and find out how much of the new code just
works, and what are the remaining issues. This might be the basis for
a book.

> Just thought I would mention it before I forgot,
> Laura
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig

--
Silent Thunder (默雷/धर्ममेघशब्दगर्ज/دھرممیگھشبدگر ج) is my name
And Children are my nation.
The Cosmos is my dwelling place, The Truth my destination.
http://earthtreasury.org/worknet (Edward Mokurai Cherlin)



-- 
Silent Thunder (默雷/धर्ममेघशब्दगर्ज/دھرممیگھشبدگر ج) is my name
And Children are my nation.
The Cosmos is my dwelling place, The Truth my destination.
http://earthtreasury.org/worknet (Edward Mokurai Cherlin)



More information about the Discuss mailing list