Turtle module

Michael F. Stemper mstemper at gmail.com
Wed May 26 10:13:54 EDT 2021


I recently discovered the turtle module and have been playing
around with it for the last few days. I've started writing some
functions for turtles, and would like to make them a bit more
robustly than what I currently have.

In particular, I'd like the state of the turtle to be more or
less the same after the function return as it was before the
function invocation.

In order to turn the turtle, I need to select a way to represent
angles. I could use either degrees or radians (or, I suppose,
grads). However, for my functions to work, I need to set the
turtle to that mode. This means that I could possibly mess up
things for the caller. What I would like to do is capture the
angle-representation mode on entry and restore it on return.
However, looking through the methods of turtle.Turtle(), I
can't find any means of capturing this information.

Similarly, I'd like to return with the pen in the same state
(up or down) as when my functions were called. Again, I can't
find any way to query the pen state.

How can my function get this information? Or do I need to be
sloppy and let the callers beware?

-- 
Michael F. Stemper
2 Chronicles 19:7


More information about the Python-list mailing list