[Edu-sig] suggestions about turtle.py

Christian Mascher christian.mascher at gmx.de
Wed Mar 1 09:38:00 CET 2006


Hi all,

some years ago I had to teach using a macintosh lab: due to some 
problems with Tk on mac there was no Idle (and no turtle.py IIRC). That 
was when I realized how useful the "batteries included" Idle (-n) 
together with the old turle.py really was for me. It is my standard 
"graphics package".

I once used it to demonstrate the adding up of arrows for physics 
(arrows representing sine-waves with different phases like from a 
grating): you could script this from idle and look at the different 
resulting amplitudes for different angles (arrow spirals curling up or 
not). Physicists will know what I mean. A Turtle was exactly the right 
tool to do this.

As a quick way to introduce loops etc. with visual feedback the turtle 
has always worked out well in my (school) classes: ages 15-17.

I also like it that the old turtle.py lets you decide if you want to do 
it procedural (module-level functions) or OO-like. And if you want to 
hide the things you don't need or rename methods etc. just implement an 
appropriate intermediate module with your favorite settings and put it 
in the pythonpath for the class to import:

# ooTurtle.py
from turtle import Pen
class Turtle:
	def __init__(self, mycolor='black'):
		self._pen=Pen()
		self.color(mycolor)
	def color(self,*args):
		self._pen.color(*args)
...

So dir(Turtle) will only show the methods you explicitly put in there. 
And you can have the names that you want.

Gregor Lingl wrote:
> 
> In the meantime (and looking forward to preparing a second edition
> of my book) I've been working on a new turtle graphics module - I named 
> it Xturtle.py.

BTW, I like your book.

> 1) I submit my Xturtle.py module along with a set of 10+ demo samples.
> I've zipped them into a package and I'll try to submit them as
> an attachment in a separate follow up posting.

Great stuff.

 > Moreover let's remember, that
> turtle graphics was invented to teach programming to very young people.
> So let's do it in a way, that interesting things can easily be done with it.

Still: "young" could be quite old. I still like to play around with 
turtles...

> (a) How about compatibility? Should every old turtle program  be 
> executable with the amended module? Remind that there is some
> strange behaviour in the old module concerning fill. IMO it should be 
> discussed if the "radians"-mode in turtle.py should be retained. (Is it 
> really useful?)

As I could rename methods (i.e. to German) anyway, backwards 
compatibility isn't that important. I just need to find the things I 
need. Fixing things to go with a new turtle-module shouldn't be 
difficult. But there should always be an Out-of-the-Box turtle in the 
standard installation.

> (c) I'd propose to add a sort of TurtleCanvas class to the turtle 
> module. 

Seems reasonable to me.

Just my 2c.

Cheers

Christian



More information about the Edu-sig mailing list