Removing/destroying a turtle from a screen

オープン
#93,642 コメント 1 件 リアクション 13 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

まず TurtleScreen API と、issue で挙げられている既存の turtle メソッド、特に hideturtle() と clear() を読んでください。turtle が screen にどのように関連付けられているか、またそのライフサイクルを対象とするテストを確認してください。screen.remove(turtle) 操作によって指定された turtle を切り離し、回収できるようになれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
77.2k
フォーク
36k
平均マージ
1日 9時間
マージ済み PR(30日)
558

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python/cpython のほかの issue

python/cpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。