On teaching programming with Python 3.0
I’ve been doing a lot of thinking lately about Python 3.0 and the impact it might have on our teaching of the language to our first-year students - most of whom have done little or no programming before.
I’ve written a paper about the issues; you might want to check it out if you have an interest in the teaching of programming using Python.
April 8th, 2008 at 8:13 pm
I’ve just submitted r62226 to http://svn.python.org/view/sandbox/trunk/2to3/ that will make 2to3 produce more idiomatic code when given “return max(self.data.values())”. I’ll also see what I can do about reducing the redundancy in “isinstance(x, (int, long))” -> “isinstance(x, (int, int))”.
As for the division issue you point out, I doubt 2to3 will ever be able to handle that: generalized type inference is out of our scope. Python 2.6’s future compatibility mode (the -3 flag) should be able to handle this, though. I can bring it up with Guido.
There may be something I can do about the range() problem, though. I’ll let you know. I’ve filed http://bugs.python.org/issue2596 to track the issue.
April 8th, 2008 at 9:07 pm
Very interesting paper. Thank you for sharing.
April 9th, 2008 at 12:09 am
Collin: thanks for this. Our experiments have reassured us that 2to3 is already a pretty effective tool for assisting with the transition to 3.0, but further refinement would of course be very welcome!
Andre: glad you found it to be interesting!
April 9th, 2008 at 12:09 pm
You state “it is no longer possible to sort lists that contain a mixture of incompatible types”, but this isn’t really the case. You can always define your own comparison operator that defines some ordering for the incompatible types, and pass that to sort.
The difference with 3.0 is that you can no longer blame Guido!
April 9th, 2008 at 12:22 pm
ricegf: that’s certainly true. I can’t think of many use cases where you’d want to return the old behaviour, though.