MCPcopy Index your code
hub / github.com/python/cpython / clearstamps

Method clearstamps

Lib/turtle.py:3234–3260  ·  view source on GitHub ↗

Delete all or first/last n of turtle's stamps. Optional argument: n -- an integer If n is None, delete all of pen's stamps, else if n > 0 delete first n stamps else if n < 0 delete last n stamps. Example (for a Turtle instance named turtle):

(self, n=None)

Source from the content-addressed store, hash-verified

3232 self._update()
3233
3234 def clearstamps(self, n=None):
3235 """Delete all or first/last n of turtle&#x27;s stamps.
3236
3237 Optional argument:
3238 n -- an integer
3239
3240 If n is None, delete all of pen&#x27;s stamps,
3241 else if n > 0 delete first n stamps
3242 else if n < 0 delete last n stamps.
3243
3244 Example (for a Turtle instance named turtle):
3245 >>> for i in range(8):
3246 ... turtle.stamp(); turtle.fd(30)
3247 ...
3248 >>> turtle.clearstamps(2)
3249 >>> turtle.clearstamps(-2)
3250 >>> turtle.clearstamps()
3251 """
3252 if n is None:
3253 toDelete = self.stampItems[:]
3254 elif n >= 0:
3255 toDelete = self.stampItems[:n]
3256 else:
3257 toDelete = self.stampItems[n:]
3258 for item in toDelete:
3259 self._clearstamp(item)
3260 self._update()
3261
3262 def _goto(self, end):
3263 """Move the pen to the point end, thereby drawing a line

Callers 1

_clearMethod · 0.95

Calls 2

_clearstampMethod · 0.95
_updateMethod · 0.95

Tested by

no test coverage detected