diff --git a/Doc/library/turtle.rst b/Doc/library/turtle.rst index d84f5a9b544613..fe475ed301cf8a 100644 --- a/Doc/library/turtle.rst +++ b/Doc/library/turtle.rst @@ -212,7 +212,7 @@ Move and draw .. function:: forward(distance) fd(distance) - :param distance: a number (integer or float) + :param distance: a number Move the turtle forward by the specified *distance*, in the direction the turtle is headed. @@ -237,7 +237,7 @@ Move and draw :param distance: a number Move the turtle backward by *distance*, opposite to the direction the - turtle is headed. Do not change the turtle's heading. + turtle is headed. The turtle's heading does not change. .. doctest:: :skipif: _tkinter is None @@ -258,11 +258,12 @@ Move and draw .. function:: right(angle) rt(angle) - :param angle: a number (integer or float) + :param angle: a number - Turn turtle right by *angle* units. (Units are by default degrees, but - can be set via the :func:`degrees` and :func:`radians` functions.) Angle - orientation depends on the turtle mode, see :func:`mode`. + Turn the turtle right by the specified *angle*. The angle is measured in + degrees by default; the unit can be changed with :func:`degrees` or + :func:`radians`. How the heading is measured depends on the turtle mode, + see :func:`mode`. .. doctest:: :skipif: _tkinter is None @@ -283,11 +284,12 @@ Move and draw .. function:: left(angle) lt(angle) - :param angle: a number (integer or float) + :param angle: a number - Turn turtle left by *angle* units. (Units are by default degrees, but - can be set via the :func:`degrees` and :func:`radians` functions.) Angle - orientation depends on the turtle mode, see :func:`mode`. + Turn the turtle left by the specified *angle*. The angle is measured in + degrees by default; the unit can be changed with :func:`degrees` or + :func:`radians`. How the heading is measured depends on the turtle mode, + see :func:`mode`. .. doctest:: :skipif: _tkinter is None @@ -312,11 +314,10 @@ Move and draw :param x: a number or a pair/vector of numbers :param y: a number or ``None`` - If *y* is ``None``, *x* must be a pair of coordinates or a :class:`Vec2D` - (e.g. as returned by :func:`pos`). - - Move turtle to an absolute position. If the pen is down, draw line. Do - not change the turtle's orientation. + Move the turtle to an absolute position. If *y* is ``None``, *x* must be a + pair of coordinates or a :class:`Vec2D`, for example as returned by + :func:`pos`. If the pen is down, a line is drawn. The turtle's heading does + not change. .. doctest:: :skipif: _tkinter is None @@ -330,13 +331,13 @@ Move and draw >>> tp = turtle.pos() >>> tp (0.00,0.00) - >>> turtle.setpos(60,30) + >>> turtle.goto(60,30) >>> turtle.pos() (60.00,30.00) - >>> turtle.setpos((20,80)) + >>> turtle.goto((20,80)) >>> turtle.pos() (20.00,80.00) - >>> turtle.setpos(tp) + >>> turtle.goto(tp) >>> turtle.pos() (0.00,0.00) @@ -381,10 +382,9 @@ Move and draw .. function:: setx(x) - :param x: a number (integer or float) + :param x: a number - Set the turtle's first coordinate to *x*, leave second coordinate - unchanged. + Set the turtle's x coordinate to *x*. The y coordinate is unchanged. .. doctest:: :skipif: _tkinter is None @@ -404,9 +404,9 @@ Move and draw .. function:: sety(y) - :param y: a number (integer or float) + :param y: a number - Set the turtle's second coordinate to *y*, leave first coordinate unchanged. + Set the turtle's y coordinate to *y*. The x coordinate is unchanged. .. doctest:: :skipif: _tkinter is None @@ -427,10 +427,10 @@ Move and draw .. function:: setheading(to_angle) seth(to_angle) - :param to_angle: a number (integer or float) + :param to_angle: a number - Set the orientation of the turtle to *to_angle*. Here are some common - directions in degrees: + Set the turtle's heading to *to_angle*. Here are some common directions in + degrees: =================== ==================== standard mode logo mode @@ -451,8 +451,9 @@ Move and draw .. function:: home() - Move turtle to the origin -- coordinates (0,0) -- and set its heading to - its start-orientation (which depends on the mode, see :func:`mode`). + Move the turtle to the origin, coordinates (0,0). The turtle's heading is + set to its start orientation, which depends on the turtle mode, see + :func:`mode`. .. doctest:: :skipif: _tkinter is None @@ -478,20 +479,20 @@ Move and draw .. function:: circle(radius, extent=None, steps=None) :param radius: a number - :param extent: a number (or ``None``) - :param steps: an integer (or ``None``) + :param extent: a number or ``None`` + :param steps: an integer or ``None`` - Draw a circle with given *radius*. The center is *radius* units left of - the turtle; *extent* -- an angle -- determines which part of the circle - is drawn. If *extent* is not given, draw the entire circle. If *extent* - is not a full circle, one endpoint of the arc is the current pen - position. Draw the arc in counterclockwise direction if *radius* is - positive, otherwise in clockwise direction. Finally the direction of the - turtle is changed by the amount of *extent*. + Draw a circle with the given *radius*. The center is *radius* units left + of the turtle; *extent*, an angle, determines which part of the circle is + drawn. If *extent* is not given, draw the entire circle. If *extent* is + not a full circle, one endpoint of the arc is the current pen position. + Draw the arc in counterclockwise direction if *radius* is positive, + otherwise in clockwise direction. Finally, the turtle's heading is changed + by *extent*. As the circle is approximated by an inscribed regular polygon, *steps* - determines the number of steps to use. If not given, it will be - calculated automatically. May be used to draw regular polygons. + determines the number of steps to use. If not given, it will be calculated + automatically. May be used to draw regular polygons. .. doctest:: :skipif: _tkinter is None @@ -650,7 +651,7 @@ Tell Turtle's state .. function:: position() pos() - Return the turtle's current location (x,y) (as a :class:`Vec2D` vector). + Return the turtle's current location (x,y) as a :class:`Vec2D` vector. .. doctest:: :skipif: _tkinter is None @@ -664,9 +665,11 @@ Tell Turtle's state :param x: a number or a pair/vector of numbers or a turtle instance :param y: a number if *x* is a number, else ``None`` - Return the angle between the line from turtle position to position specified - by (x,y), the vector or the other turtle. This depends on the turtle's start - orientation which depends on the mode - "standard"/"world" or "logo". + Return the angle of the line from the turtle's position to (x,y). If *y* is + ``None``, *x* must be a pair of coordinates, a :class:`Vec2D`, for example + as returned by :func:`pos`, or another turtle. The angle is measured from + the turtle's start orientation, which depends on the turtle mode, see + :func:`mode`. .. doctest:: :skipif: _tkinter is None @@ -710,8 +713,8 @@ Tell Turtle's state .. function:: heading() - Return the turtle's current heading (value depends on the turtle mode, see - :func:`mode`). + Return the turtle's current heading. The value depends on the turtle mode, + see :func:`mode`. .. doctest:: :skipif: _tkinter is None @@ -727,8 +730,9 @@ Tell Turtle's state :param x: a number or a pair/vector of numbers or a turtle instance :param y: a number if *x* is a number, else ``None`` - Return the distance from the turtle to (x,y), the given vector, or the given - other turtle, in turtle step units. + Return the distance from the turtle to (x,y) in turtle step units. If *y* is + ``None``, *x* must be a pair of coordinates, a :class:`Vec2D`, for example + as returned by :func:`pos`, or another turtle. .. doctest:: :skipif: _tkinter is None @@ -751,8 +755,8 @@ Settings for measurement :param fullcircle: a number - Set angle measurement units, i.e. set number of "degrees" for a full circle. - Default value is 360 degrees. + Set the angle measurement units to degrees. The number of degrees in a full + circle is set to *fullcircle*, which defaults to 360. .. doctest:: :skipif: _tkinter is None @@ -775,7 +779,7 @@ Settings for measurement .. function:: radians() Set the angle measurement units to radians. Equivalent to - ``degrees(2*math.pi)``. + ``degrees(2 * math.pi)``. .. doctest:: :skipif: _tkinter is None diff --git a/Lib/turtle.py b/Lib/turtle.py index 71af2796abd6ed..851d4a7c3d55db 100644 --- a/Lib/turtle.py +++ b/Lib/turtle.py @@ -1532,13 +1532,15 @@ def save(self, filename, *, overwrite=False): onkeyrelease = onkey class TNavigator: - """Navigation part of the RawTurtle. + """The navigation part of RawTurtle. + Implements methods for turtle movement. """ START_ORIENTATION = { "standard": Vec2D(1.0, 0.0), "world" : Vec2D(1.0, 0.0), - "logo" : Vec2D(0.0, 1.0) } + "logo" : Vec2D(0.0, 1.0), + } DEFAULT_MODE = "standard" DEFAULT_ANGLEOFFSET = 0 DEFAULT_ANGLEORIENT = 1 @@ -1554,16 +1556,15 @@ def __init__(self, mode=DEFAULT_MODE): TNavigator.reset(self) def reset(self): - """reset turtle to its initial values + """Reset turtle to its initial values. - Will be overwritten by parent class + Will be overwritten by the parent class. """ self._position = Vec2D(0.0, 0.0) self._orient = TNavigator.START_ORIENTATION[self._mode] def _setmode(self, mode=None): - """Set turtle-mode to 'standard', 'world' or 'logo'. - """ + """Set the turtle's mode to 'standard', 'world' or 'logo'.""" if mode is None: return self._mode if mode not in ["standard", "logo", "world"]: @@ -1577,7 +1578,7 @@ def _setmode(self, mode=None): self._angleOrient = -1 def _setDegreesPerAU(self, fullcircle): - """Helper function for degrees() and radians()""" + """Helper function for degrees() and radians().""" self._fullcircle = fullcircle self._degreesPerAU = 360/fullcircle if self._mode == "standard": @@ -1586,55 +1587,59 @@ def _setDegreesPerAU(self, fullcircle): self._angleOffset = fullcircle/4. def degrees(self, fullcircle=360.0): - """ Set angle measurement units to degrees. + """Set the angle measurement units to degrees. - Optional argument: - fullcircle - a number + The number of degrees in a full circle is set to fullcircle, which + defaults to 360. - Set angle measurement units, i. e. set number - of 'degrees' for a full circle. Default value is - 360 degrees. + Argument: + fullcircle -- a number Example (for a Turtle instance named turtle): - >>> turtle.left(90) - >>> turtle.heading() - 90 - - Change angle measurement unit to grad (also known as gon, - grade, or gradian and equals 1/100-th of the right angle.) - >>> turtle.degrees(400.0) - >>> turtle.heading() - 100 - + >>> turtle.home() + >>> turtle.left(90) + >>> turtle.heading() + 90.0 + + >>> # Change angle measurement unit to grad (also known as gon, + >>> # grade, or gradian and equals 1/100-th of the right angle.) + >>> turtle.degrees(400.0) + >>> turtle.heading() + 100.0 + >>> turtle.degrees(360) + >>> turtle.heading() + 90.0 """ self._setDegreesPerAU(fullcircle) def radians(self): - """ Set the angle measurement units to radians. + """Set the angle measurement units to radians. - No arguments. + Equivalent to degrees(2 * math.pi). Example (for a Turtle instance named turtle): - >>> turtle.heading() - 90 - >>> turtle.radians() - >>> turtle.heading() - 1.5707963267948966 + >>> turtle.home() + >>> turtle.left(90) + >>> turtle.heading() + 90.0 + >>> turtle.radians() + >>> turtle.heading() + 1.5707963267948966 """ self._setDegreesPerAU(math.tau) def _go(self, distance): - """move turtle forward by specified distance""" + """Move the turtle forward by the specified distance.""" ende = self._position + self._orient * distance self._goto(ende) def _rotate(self, angle): - """Turn turtle counterclockwise by specified angle if angle > 0.""" + """Turn the turtle counterclockwise by specified angle, if the angle > 0.""" angle *= self._degreesPerAU self._orient = self._orient.rotate(angle) def _goto(self, end): - """move turtle to position end.""" + """Move the turtle to the end position.""" self._position = end def teleport(self, x=None, y=None, *, fill_gap: bool = False) -> None: @@ -1649,21 +1654,20 @@ def forward(self, distance): Aliases: forward | fd - Argument: - distance -- a number (integer or float) + The turtle moves in the direction it is headed. - Move the turtle forward by the specified distance, in the direction - the turtle is headed. + Argument: + distance -- a number Example (for a Turtle instance named turtle): - >>> turtle.position() - (0.00,0.00) - >>> turtle.forward(25) - >>> turtle.position() - (25.00,0.00) - >>> turtle.forward(-75) - >>> turtle.position() - (-50.00,0.00) + >>> turtle.position() + (0.00,0.00) + >>> turtle.forward(25) + >>> turtle.position() + (25.00,0.00) + >>> turtle.forward(-75) + >>> turtle.position() + (-50.00,0.00) """ self._go(distance) @@ -1672,134 +1676,125 @@ def back(self, distance): Aliases: back | backward | bk - Argument: - distance -- a number + The turtle moves opposite to the direction it is headed. + The turtle's heading does not change. - Move the turtle backward by distance, opposite to the direction the - turtle is headed. Do not change the turtle's heading. + Argument: + distance -- a number Example (for a Turtle instance named turtle): - >>> turtle.position() - (0.00,0.00) - >>> turtle.backward(30) - >>> turtle.position() - (-30.00,0.00) + >>> turtle.position() + (0.00,0.00) + >>> turtle.backward(30) + >>> turtle.position() + (-30.00,0.00) """ self._go(-distance) def right(self, angle): - """Turn turtle right by angle units. + """Turn the turtle right by the specified angle. Aliases: right | rt - Argument: - angle -- a number (integer or float) + The angle is measured in degrees by default; the unit can be + changed with degrees() or radians(). How the heading is measured + depends on the turtle mode, see mode(). - Turn turtle right by angle units. (Units are by default degrees, - but can be set via the degrees() and radians() functions.) - Angle orientation depends on mode. (See this.) + Argument: + angle -- a number Example (for a Turtle instance named turtle): - >>> turtle.heading() - 22.0 - >>> turtle.right(45) - >>> turtle.heading() - 337.0 + >>> turtle.heading() + 22.0 + >>> turtle.right(45) + >>> turtle.heading() + 337.0 """ self._rotate(-angle) def left(self, angle): - """Turn turtle left by angle units. + """Turn the turtle left by the specified angle. Aliases: left | lt - Argument: - angle -- a number (integer or float) + The angle is measured in degrees by default; the unit can be + changed with degrees() or radians(). How the heading is measured + depends on the turtle mode, see mode(). - Turn turtle left by angle units. (Units are by default degrees, - but can be set via the degrees() and radians() functions.) - Angle orientation depends on mode. (See this.) + Argument: + angle -- a number Example (for a Turtle instance named turtle): - >>> turtle.heading() - 22.0 - >>> turtle.left(45) - >>> turtle.heading() - 67.0 + >>> turtle.heading() + 22.0 + >>> turtle.left(45) + >>> turtle.heading() + 67.0 """ self._rotate(angle) def pos(self): - """Return the turtle's current location (x,y), as a Vec2D-vector. + """Return the turtle's current location (x,y) as a Vec2D vector. Aliases: pos | position - No arguments. - Example (for a Turtle instance named turtle): - >>> turtle.pos() - (0.00, 240.00) + >>> turtle.pos() + (0.00,240.00) """ return self._position def xcor(self): - """ Return the turtle's x coordinate. - - No arguments. + """Return the turtle's x coordinate. Example (for a Turtle instance named turtle): - >>> reset() - >>> turtle.left(60) - >>> turtle.forward(100) - >>> print(turtle.xcor()) - 50.0 + >>> turtle.home() + >>> turtle.left(50) + >>> turtle.forward(100) + >>> print(round(turtle.xcor(), 5)) + 64.27876 """ return self._position[0] def ycor(self): - """ Return the turtle's y coordinate - --- - No arguments. + """Return the turtle's y coordinate Example (for a Turtle instance named turtle): - >>> reset() - >>> turtle.left(60) - >>> turtle.forward(100) - >>> print(turtle.ycor()) - 86.6025403784 + >>> reset() + >>> turtle.left(60) + >>> turtle.forward(100) + >>> print(round(turtle.ycor(), 5)) + 86.60254 """ return self._position[1] def goto(self, x, y=None): - """Move turtle to an absolute position. - - Aliases: setpos | setposition | goto: + """Move the turtle to an absolute position. - Arguments: - x -- a number or a pair/vector of numbers - y -- a number None + Aliases: goto | setpos | setposition - call: goto(x, y) # two coordinates - --or: goto((x, y)) # a pair (tuple) of coordinates - --or: goto(vec) # e.g. as returned by pos() + If y is None, x must be a pair of coordinates or a Vec2D, for + example as returned by pos(). If the pen is down, a line is drawn. + The turtle's heading does not change. - Move turtle to an absolute position. If the pen is down, - a line will be drawn. The turtle's orientation does not change. + Arguments: + x -- a number or a pair/vector of numbers + y -- a number or None Example (for a Turtle instance named turtle): - >>> tp = turtle.pos() - >>> tp - (0.00,0.00) - >>> turtle.setpos(60,30) - >>> turtle.pos() - (60.00,30.00) - >>> turtle.setpos((20,80)) - >>> turtle.pos() - (20.00,80.00) - >>> turtle.setpos(tp) - >>> turtle.pos() - (0.00,0.00) + >>> tp = turtle.pos() + >>> tp + (0.00,0.00) + >>> turtle.goto(60,30) + >>> turtle.pos() + (60.00,30.00) + >>> turtle.goto((20,80)) + >>> turtle.pos() + (20.00,80.00) + >>> turtle.goto(tp) + >>> turtle.pos() + (0.00,0.00) """ if y is None: self._goto(Vec2D(*x)) @@ -1807,76 +1802,79 @@ def goto(self, x, y=None): self._goto(Vec2D(x, y)) def home(self): - """Move turtle to the origin - coordinates (0,0). - - No arguments. + """Move the turtle to the origin, coordinates (0,0). - Move turtle to the origin - coordinates (0,0) and set its - heading to its start-orientation (which depends on mode). + The turtle's heading is set to its start orientation, which + depends on the turtle mode, see mode(). Example (for a Turtle instance named turtle): - >>> turtle.home() + >>> turtle.heading() + 90.0 + >>> turtle.position() + (0.00,-10.00) + >>> turtle.home() + >>> turtle.position() + (0.00,0.00) + >>> turtle.heading() + 0.0 """ self.goto(0, 0) self.setheading(0) def setx(self, x): - """Set the turtle's first coordinate to x + """Set the turtle's x coordinate to x. - Argument: - x -- a number (integer or float) + The y coordinate is unchanged. - Set the turtle's first coordinate to x, leave second coordinate - unchanged. + Argument: + x -- a number Example (for a Turtle instance named turtle): - >>> turtle.position() - (0.00, 240.00) - >>> turtle.setx(10) - >>> turtle.position() - (10.00, 240.00) + >>> turtle.position() + (0.00,240.00) + >>> turtle.setx(10) + >>> turtle.position() + (10.00,240.00) """ self._goto(Vec2D(x, self._position[1])) def sety(self, y): - """Set the turtle's second coordinate to y + """Set the turtle's y coordinate to y. - Argument: - y -- a number (integer or float) + The x coordinate is unchanged. - Set the turtle's first coordinate to x, second coordinate remains - unchanged. + Argument: + y -- a number Example (for a Turtle instance named turtle): - >>> turtle.position() - (0.00, 40.00) - >>> turtle.sety(-10) - >>> turtle.position() - (0.00, -10.00) + >>> turtle.position() + (0.00,40.00) + >>> turtle.sety(-10) + >>> turtle.position() + (0.00,-10.00) """ self._goto(Vec2D(self._position[0], y)) def distance(self, x, y=None): """Return the distance from the turtle to (x,y) in turtle step units. - Arguments: - x -- a number or a pair/vector of numbers or a turtle instance - y -- a number None None + If y is None, x must be a pair of coordinates, a Vec2D, for example + as returned by pos(), or another turtle. - call: distance(x, y) # two coordinates - --or: distance((x, y)) # a pair (tuple) of coordinates - --or: distance(vec) # e.g. as returned by pos() - --or: distance(mypen) # where mypen is another turtle + Arguments: + x -- a number or a pair/vector of numbers or a turtle instance + y -- a number if x is a number, else None Example (for a Turtle instance named turtle): - >>> turtle.pos() - (0.00,0.00) - >>> turtle.distance(30,40) - 50.0 - >>> pen = Turtle() - >>> pen.forward(77) - >>> turtle.distance(pen) - 77.0 + >>> turtle.home() + >>> turtle.distance(30,40) + 50.0 + >>> turtle.distance((30,40)) + 50.0 + >>> joe = Turtle() + >>> joe.forward(77) + >>> turtle.distance(joe) + 77.0 """ if y is not None: pos = Vec2D(x, y) @@ -1889,26 +1887,21 @@ def distance(self, x, y=None): return abs(pos - self._position) def towards(self, x, y=None): - """Return the angle of the line from the turtle's position to (x, y). + """Return the angle of the line from the turtle's position to (x,y). - Arguments: - x -- a number or a pair/vector of numbers or a turtle instance - y -- a number None None + If y is None, x must be a pair of coordinates, a Vec2D, for example + as returned by pos(), or another turtle. The angle is measured from + the turtle's start orientation, which depends on the turtle mode, + see mode(). - call: distance(x, y) # two coordinates - --or: distance((x, y)) # a pair (tuple) of coordinates - --or: distance(vec) # e.g. as returned by pos() - --or: distance(mypen) # where mypen is another turtle - - Return the angle, between the line from turtle-position to position - specified by x, y and the turtle's start orientation. (Depends on - modes - "standard" or "logo") + Arguments: + x -- a number or a pair/vector of numbers or a turtle instance + y -- a number if x is a number, else None Example (for a Turtle instance named turtle): - >>> turtle.pos() - (10.00, 10.00) - >>> turtle.towards(0,0) - 225.0 + >>> turtle.goto(10, 10) + >>> turtle.towards(0,0) + 225.0 """ if y is not None: pos = Vec2D(x, y) @@ -1924,14 +1917,15 @@ def towards(self, x, y=None): return (self._angleOffset + self._angleOrient*result) % self._fullcircle def heading(self): - """ Return the turtle's current heading. + """Return the turtle's current heading. - No arguments. + The value depends on the turtle mode, see mode(). Example (for a Turtle instance named turtle): - >>> turtle.left(67) - >>> turtle.heading() - 67.0 + >>> turtle.home() + >>> turtle.left(67) + >>> turtle.heading() + 67.0 """ x, y = self._orient result = round(math.degrees(math.atan2(y, x)), 10) % 360.0 @@ -1939,62 +1933,56 @@ def heading(self): return (self._angleOffset + self._angleOrient*result) % self._fullcircle def setheading(self, to_angle): - """Set the orientation of the turtle to to_angle. + """Set the turtle's heading to to_angle. - Aliases: setheading | seth - - Argument: - to_angle -- a number (integer or float) + Aliases: setheading | seth - Set the orientation of the turtle to to_angle. Here are some common directions in degrees: - standard - mode: logo-mode: - -------------------|-------------------- - 0 - east 0 - north - 90 - north 90 - east - 180 - west 180 - south - 270 - south 270 - west + standard mode logo mode + -------------------|--------------- + 0 - east 0 - north + 90 - north 90 - east + 180 - west 180 - south + 270 - south 270 - west + + Argument: + to_angle -- a number Example (for a Turtle instance named turtle): - >>> turtle.setheading(90) - >>> turtle.heading() - 90 + >>> turtle.setheading(90) + >>> turtle.heading() + 90.0 """ - angle = (to_angle - self.heading())*self._angleOrient + angle = (to_angle - self.heading()) * self._angleOrient full = self._fullcircle angle = (angle+full/2.)%full - full/2. self._rotate(angle) def circle(self, radius, extent = None, steps = None): - """ Draw a circle with given radius. + """Draw a circle with the given radius. - Arguments: - radius -- a number - extent (optional) -- a number - steps (optional) -- an integer - - Draw a circle with given radius. The center is radius units left - of the turtle; extent - an angle - determines which part of the - circle is drawn. If extent is not given, draw the entire circle. - If extent is not a full circle, one endpoint of the arc is the - current pen position. Draw the arc in counterclockwise direction - if radius is positive, otherwise in clockwise direction. Finally - the direction of the turtle is changed by the amount of extent. + The center is radius units left of the turtle; extent, an angle, + determines which part of the circle is drawn. If extent is not + given, draw the entire circle. If extent is not a full circle, one + endpoint of the arc is the current pen position. Draw the arc in + the counterclockwise direction if radius is positive, otherwise in + the clockwise direction. Finally, the turtle's heading is changed by + extent. As the circle is approximated by an inscribed regular polygon, - steps determines the number of steps to use. If not given, - it will be calculated automatically. Maybe used to draw regular + steps determines the number of steps to use. If not given, it + will be calculated automatically. May be used to draw regular polygons. - call: circle(radius) # full circle - --or: circle(radius, extent) # arc - --or: circle(radius, extent, steps) - --or: circle(radius, steps=6) # 6-sided polygon + Arguments: + radius -- a number + extent -- a number or None + steps -- an integer or None Example (for a Turtle instance named turtle): - >>> turtle.circle(50) - >>> turtle.circle(120, 180) # semicircle + >>> turtle.circle(50) + >>> turtle.circle(120, 180) # draw a semicircle """ if self.undobuffer: self.undobuffer.push(["seq"]) @@ -2029,14 +2017,16 @@ def circle(self, radius, extent = None, steps = None): if self.undobuffer: self.undobuffer.cumulate = False -## three dummy methods to be implemented by child class: + # Three dummy methods to be implemented by the child class: def speed(self, s=0): - """dummy method - to be overwritten by child class""" + """Dummy method - to be overwritten by the child class.""" def _tracer(self, a=None, b=None): - """dummy method - to be overwritten by child class""" + """Dummy method - to be overwritten by the child class.""" def _delay(self, n=None): - """dummy method - to be overwritten by child class""" + """Dummy method - to be overwritten by the child class.""" + + # Aliases for the commonly used commands: fd = forward bk = back