MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / clearstamps

Method clearstamps

Python/Turtle.py:3015–3041  ·  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

3013 self._update()
3014
3015 def clearstamps(self, n=None):
3016 """Delete all or first/last n of turtle&#x27;s stamps.
3017
3018 Optional argument:
3019 n -- an integer
3020
3021 If n is None, delete all of pen&#x27;s stamps,
3022 else if n > 0 delete first n stamps
3023 else if n < 0 delete last n stamps.
3024
3025 Example (for a Turtle instance named turtle):
3026 >>> for i in range(8):
3027 ... turtle.stamp(); turtle.fd(30)
3028 ...
3029 >>> turtle.clearstamps(2)
3030 >>> turtle.clearstamps(-2)
3031 >>> turtle.clearstamps()
3032 """
3033 if n is None:
3034 toDelete = self.stampItems[:]
3035 elif n >= 0:
3036 toDelete = self.stampItems[:n]
3037 else:
3038 toDelete = self.stampItems[n:]
3039 for item in toDelete:
3040 self._clearstamp(item)
3041 self._update()
3042
3043 def _goto(self, end):
3044 """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