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

Laura Creighton lac at openend.se
Sun Apr 19 22:05:43 CEST 2009


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?

Laura


More information about the Edu-sig mailing list