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

Method poly

Lib/turtle.py:3570–3588  ·  view source on GitHub ↗

A context manager for recording the vertices of a polygon. Implicitly ensures that the code block is wrapped with begin_poly() and end_poly() Example (for a Turtle instance named turtle) where we create a triangle as the polygon and move the turtle 100 steps forward

(self)

Source from the content-addressed store, hash-verified

3568
3569 @contextmanager
3570 def poly(self):
3571 """A context manager for recording the vertices of a polygon.
3572
3573 Implicitly ensures that the code block is wrapped with
3574 begin_poly() and end_poly()
3575
3576 Example (for a Turtle instance named turtle) where we create a
3577 triangle as the polygon and move the turtle 100 steps forward:
3578 >>> with turtle.poly():
3579 ... for side in range(3)
3580 ... turtle.forward(50)
3581 ... turtle.right(60)
3582 >>> turtle.forward(100)
3583 """
3584 self.begin_poly()
3585 try:
3586 yield
3587 finally:
3588 self.end_poly()
3589
3590 def begin_poly(self):
3591 """Start recording the vertices of a polygon.

Calls 2

begin_polyMethod · 0.95
end_polyMethod · 0.95

Tested by 3

test_polyMethod · 0.64