Skip to content

Removing/destroying a turtle from a screen #93642

@karelhusa

Description

@karelhusa

Feature or enhancement
Add new TurtleScreen method to remove a specific turtle.
screen.remove(turtle)

The turtle will be removed and no longer associated with the screen. Finally the object can be collected by the garbace collector.

Pitch

Turtle is a great way to learn Python and we use it with students to make simple games. In some games we create many turtles.

When I create a new turtle with:
my_turtle = turtle.Turtle()

I can:

  • hide it with turtle.hideturtle()
  • clear the drawing with turtle.clear()

However, I have no simple way to remove (destroy) the turtle.

It's a good programming practice to free the object that is no longer being used, so I would like to remove the unused turtles. Otherwise the turtles are piling up.

Previous discussion
This missing feature is discussed at multiple places on the web, e.g.:
https://stackoverflow.com/questions/43972351/how-to-fully-delete-a-turtle
There is no simple solution so far, rather complicated.

And since "Simple is better than complex. Complex is better than complicated." I propose this enhancement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions