On Thu, May 27, 2021 at 6:51 AM Michael F. Stemper <mstem...@gmail.com> wrote: > > On 26/05/2021 11.17, Chris Angelico wrote: > > On Thu, May 27, 2021 at 1:59 AM Michael F. Stemper <mstem...@gmail.com> > > wrote: > > > >> 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 > > Just found the same thing myself and came back to report it. But, > immediately after your link is: > <https://docs.python.org/3/library/turtle.html#turtle.isdown> > which seems even better for up/down.
Yeah, if that's the only thing you need. > > 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! > > Well, I'll take your advice and not use it. Seems really sloppy to > change an attribute of an object as a side-effect, but I guess that > I'll have to be sloppy. > If this matters to you, here's what I'd recommend: Propose that the fullcircle state be added to what pen() returns and can update, and also possibly propose a context manager, so you can do something like this: def f(): with turt.local(): turt.pendown() ... .... # once we get here, the turtle's pen state will have been restored I'm not the person to ask about these, as I don't use the turtle module, but those would seem fairly plausible enhancements. ChrisA -- https://mail.python.org/mailman/listinfo/python-list