Removing/destroying a turtle from a screen

Open
#93,642 1 comment 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start by reading the TurtleScreen API and the existing turtle methods named in the issue, especially hideturtle() and clear(). Check how turtles are associated with a screen and what tests cover their lifecycle; done should provide a screen.remove(turtle) operation that detaches the specified turtle and permits collection.

Written by the indexing model from the issue text.

Description

stdlib type-feature

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.

Dominant language
Python
Stars
77.2k
Forks
36k
Avg merge
1d 9h
Merged PRs (30d)
558

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/cpython

All issues in python/cpython

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.