Turtle module

Chris Angelico rosuav at gmail.com
Wed May 26 12:17:27 EDT 2021


On Thu, May 27, 2021 at 1:59 AM Michael F. Stemper <mstemper at gmail.com> wrote:
> 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?

For the most part, this is what you want:

https://docs.python.org/3/library/turtle.html#turtle.pen

It doesn't seem to include the fullcircle state (which is what
.degrees() and .radians() set), and I'm not sure why. Worst case, it
is technically available as the ._fullcircle member, but I would
advise against using that if you can help it!

ChrisA


More information about the Python-list mailing list