classification
Title: Teleport method for turtle class
Type: enhancement Stage:
Components: Tkinter Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Muffinlicious, serhiy.storchaka, veky
Priority: normal Keywords:

Created on 2021-07-12 06:48 by Muffinlicious, last changed 2021-07-12 17:42 by Muffinlicious.

Messages (4)
msg397286 - (view) Author: Muffinlicious (Muffinlicious) Date: 2021-07-12 06:48
I use turtle pretty often in a teaching setting. It's extremely common that I'll define the following function at the top of my code:

def teleport(x, y):
    turtle.penup()
    turtle.setpos(x, y)
    turtle.pendown()

Shouldn't this sort of method already exist within the turtle class?
msg397292 - (view) Author: Vedran Čačić (veky) * Date: 2021-07-12 09:37
In my view, turtle is a great tool for exploring _polar_ coordinates. If you set emphasis to rectangular coordinates, there are many tools that are much better.

Second, your function might be ok for you, but it is really not suitable for standard library. Probably you meant something like (a method)

    def teleport(self, *args):
        restore = self.isdown()
        self.penup()
        self.setpos(*args)
        if restore: self.pendown()
msg397303 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-07-12 12:33
What other Turtle implementations support the teleport command?
msg397341 - (view) Author: Muffinlicious (Muffinlicious) Date: 2021-07-12 17:42
Turtle is  the most accessible and well-known drawing module for kids to use so teleporting makes more sense in the context of drawing random shapes or small pictures around the screen. I've seen the penup/goto/pendown combo so often that I figure it at least warrants a suggestion. Also my crappy function was mostly just meant as an outline, haha.
History
Date User Action Args
2021-07-12 17:42:12Muffinlicioussetmessages: + msg397341
2021-07-12 12:33:22serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg397303
2021-07-12 09:37:51vekysetnosy: + veky
messages: + msg397292
2021-07-12 06:48:56Muffinliciouscreate