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

Method undo

Python/Turtle.py:3521–3548  ·  view source on GitHub ↗

undo (repeatedly) the last turtle action. No argument. undo (repeatedly) the last turtle action. Number of available undo actions is determined by the size of the undobuffer. Example (for a Turtle instance named turtle): >>> for i in range(4):

(self)

Source from the content-addressed store, hash-verified

3519 self.undobuffer.pop()
3520
3521 def undo(self):
3522 """undo (repeatedly) the last turtle action.
3523
3524 No argument.
3525
3526 undo (repeatedly) the last turtle action.
3527 Number of available undo actions is determined by the size of
3528 the undobuffer.
3529
3530 Example (for a Turtle instance named turtle):
3531 >>> for i in range(4):
3532 ... turtle.fd(50); turtle.lt(80)
3533 ...
3534 >>> for i in range(8):
3535 ... turtle.undo()
3536 ...
3537 """
3538 if self.undobuffer is None:
3539 return
3540 item = self.undobuffer.pop()
3541 action = item[0]
3542 data = item[1:]
3543 if action == "seq":
3544 while data:
3545 item = data.pop()
3546 self._undo(item[0], item[1:])
3547 else:
3548 self._undo(action, data)
3549
3550 turtlesize = shapesize
3551

Callers 1

demo2Function · 0.80

Calls 2

_undoMethod · 0.95
popMethod · 0.45

Tested by

no test coverage detected