[Edu-sig] What version of Python to teach ....

Edward Cherlin echerlin at gmail.com
Sun Apr 19 23:25:29 CEST 2009


Comment at end.

On Sun, Apr 19, 2009 at 1:05 PM, Laura Creighton <lac at openend.se> wrote:
> In a message of Sun, 19 Apr 2009 12:49:17 PDT, Edward Cherlin writes:
>>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 t
>>hat
>>> 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 practic
>>e,
>>> 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 t
>>o
>>> 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
>
> You are suggesting that students will need to learn how to use a refactoring
> tool before they can sit down and read a piece of pre 3.0 code for
> pleasure and edification?

No, I'm suggesting that an introductory course on Python 3.0 can make
use of converted and lightly massaged code, and ignore Python 2.x
until students have wrapped their minds around one version. Computer
Science students are not necessarily interested in commercial
programming, and may never need to learn 2.x. People learning Python
in order to write their own programs, ditto. The original question was
how to get enough educational examples in Python 3.0.

For the larger problem of converting existing 2.x libraries and
applications in order to have more 3.0 to read, that will solve itself
in the normal course of events. See Guido's advice.

http://docs.python.org/3.0/whatsnew/3.0.html

What’s New In Python 3.0

Porting To Python 3.0

The Web page I cited says explicitly that the instructor converted all
of his current teaching examples using 2to3, so the students don't
even have to know about it in order to get started.

I'm also suggesting to FLOSS Manuals and O'Reilly that we could do a
book on converting 2.x to, 3.0 in short order, and get it out before
it becomes obsolete. ^_^

> Laura
>



-- 
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 Edu-sig mailing list