Skip to content

Commit bcd7c09

Browse files
Tidy up turtle motion docstrings and docs in turtle module
1 parent 7352b6a commit bcd7c09

2 files changed

Lines changed: 267 additions & 273 deletions

File tree

‎Doc/library/turtle.rst‎

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Move and draw
213213
.. function:: forward(distance)
214214
fd(distance)
215215

216-
:param distance: a number (integer or float)
216+
:param distance: a number
217217

218218
Move the turtle forward by the specified *distance*, in the direction the
219219
turtle is headed.
@@ -238,7 +238,7 @@ Move and draw
238238
:param distance: a number
239239

240240
Move the turtle backward by *distance*, opposite to the direction the
241-
turtle is headed. Do not change the turtle's heading.
241+
turtle is headed. The turtle's heading does not change.
242242

243243
.. doctest::
244244
:skipif: _tkinter is None
@@ -259,11 +259,12 @@ Move and draw
259259
.. function:: right(angle)
260260
rt(angle)
261261

262-
:param angle: a number (integer or float)
262+
:param angle: a number
263263

264-
Turn turtle right by *angle* units. (Units are by default degrees, but
265-
can be set via the :func:`degrees` and :func:`radians` functions.) Angle
266-
orientation depends on the turtle mode, see :func:`mode`.
264+
Turn the turtle right by the specified *angle*. The angle is measured in
265+
degrees by default; the unit can be changed with :func:`degrees` or
266+
:func:`radians`. How the heading is measured depends on the turtle mode,
267+
see :func:`mode`.
267268

268269
.. doctest::
269270
:skipif: _tkinter is None
@@ -284,11 +285,12 @@ Move and draw
284285
.. function:: left(angle)
285286
lt(angle)
286287

287-
:param angle: a number (integer or float)
288+
:param angle: a number
288289

289-
Turn turtle left by *angle* units. (Units are by default degrees, but
290-
can be set via the :func:`degrees` and :func:`radians` functions.) Angle
291-
orientation depends on the turtle mode, see :func:`mode`.
290+
Turn the turtle left by the specified *angle*. The angle is measured in
291+
degrees by default; the unit can be changed with :func:`degrees` or
292+
:func:`radians`. How the heading is measured depends on the turtle mode,
293+
see :func:`mode`.
292294

293295
.. doctest::
294296
:skipif: _tkinter is None
@@ -313,11 +315,10 @@ Move and draw
313315
:param x: a number or a pair/vector of numbers
314316
:param y: a number or ``None``
315317

316-
If *y* is ``None``, *x* must be a pair of coordinates or a :class:`Vec2D`
317-
(e.g. as returned by :func:`pos`).
318-
319-
Move turtle to an absolute position. If the pen is down, draw line. Do
320-
not change the turtle's orientation.
318+
Move the turtle to an absolute position. If *y* is ``None``, *x* must be a
319+
pair of coordinates or a :class:`Vec2D`, for example as returned by
320+
:func:`pos`. If the pen is down, a line is drawn. The turtle's heading does
321+
not change.
321322

322323
.. doctest::
323324
:skipif: _tkinter is None
@@ -331,13 +332,13 @@ Move and draw
331332
>>> tp = turtle.pos()
332333
>>> tp
333334
(0.00,0.00)
334-
>>> turtle.setpos(60,30)
335+
>>> turtle.goto(60,30)
335336
>>> turtle.pos()
336337
(60.00,30.00)
337-
>>> turtle.setpos((20,80))
338+
>>> turtle.goto((20,80))
338339
>>> turtle.pos()
339340
(20.00,80.00)
340-
>>> turtle.setpos(tp)
341+
>>> turtle.goto(tp)
341342
>>> turtle.pos()
342343
(0.00,0.00)
343344

@@ -382,10 +383,9 @@ Move and draw
382383

383384
.. function:: setx(x)
384385

385-
:param x: a number (integer or float)
386+
:param x: a number
386387

387-
Set the turtle's first coordinate to *x*, leave second coordinate
388-
unchanged.
388+
Set the turtle's x coordinate to *x*. The y coordinate is unchanged.
389389

390390
.. doctest::
391391
:skipif: _tkinter is None
@@ -405,9 +405,9 @@ Move and draw
405405

406406
.. function:: sety(y)
407407

408-
:param y: a number (integer or float)
408+
:param y: a number
409409

410-
Set the turtle's second coordinate to *y*, leave first coordinate unchanged.
410+
Set the turtle's y coordinate to *y*. The x coordinate is unchanged.
411411

412412
.. doctest::
413413
:skipif: _tkinter is None
@@ -428,10 +428,10 @@ Move and draw
428428
.. function:: setheading(to_angle)
429429
seth(to_angle)
430430

431-
:param to_angle: a number (integer or float)
431+
:param to_angle: a number
432432

433-
Set the orientation of the turtle to *to_angle*. Here are some common
434-
directions in degrees:
433+
Set the turtle's heading to *to_angle*. Here are some common directions in
434+
degrees:
435435

436436
=================== ====================
437437
standard mode logo mode
@@ -452,8 +452,9 @@ Move and draw
452452

453453
.. function:: home()
454454

455-
Move turtle to the origin -- coordinates (0,0) -- and set its heading to
456-
its start-orientation (which depends on the mode, see :func:`mode`).
455+
Move the turtle to the origin, coordinates (0,0). The turtle's heading is
456+
set to its start orientation, which depends on the turtle mode, see
457+
:func:`mode`.
457458

458459
.. doctest::
459460
:skipif: _tkinter is None
@@ -479,20 +480,20 @@ Move and draw
479480
.. function:: circle(radius, extent=None, steps=None)
480481

481482
:param radius: a number
482-
:param extent: a number (or ``None``)
483-
:param steps: an integer (or ``None``)
483+
:param extent: a number or ``None``
484+
:param steps: an integer or ``None``
484485

485-
Draw a circle with given *radius*. The center is *radius* units left of
486-
the turtle; *extent* -- an angle -- determines which part of the circle
487-
is drawn. If *extent* is not given, draw the entire circle. If *extent*
488-
is not a full circle, one endpoint of the arc is the current pen
489-
position. Draw the arc in counterclockwise direction if *radius* is
490-
positive, otherwise in clockwise direction. Finally the direction of the
491-
turtle is changed by the amount of *extent*.
486+
Draw a circle with the given *radius*. The center is *radius* units left
487+
of the turtle; *extent*, an angle, determines which part of the circle is
488+
drawn. If *extent* is not given, draw the entire circle. If *extent* is
489+
not a full circle, one endpoint of the arc is the current pen position.
490+
Draw the arc in counterclockwise direction if *radius* is positive,
491+
otherwise in clockwise direction. Finally, the turtle's heading is changed
492+
by *extent*.
492493

493494
As the circle is approximated by an inscribed regular polygon, *steps*
494-
determines the number of steps to use. If not given, it will be
495-
calculated automatically. May be used to draw regular polygons.
495+
determines the number of steps to use. If not given, it will be calculated
496+
automatically. May be used to draw regular polygons.
496497

497498
.. doctest::
498499
:skipif: _tkinter is None
@@ -651,7 +652,7 @@ Tell Turtle's state
651652
.. function:: position()
652653
pos()
653654

654-
Return the turtle's current location (x,y) (as a :class:`Vec2D` vector).
655+
Return the turtle's current location (x,y) as a :class:`Vec2D` vector.
655656

656657
.. doctest::
657658
:skipif: _tkinter is None
@@ -665,9 +666,11 @@ Tell Turtle's state
665666
:param x: a number or a pair/vector of numbers or a turtle instance
666667
:param y: a number if *x* is a number, else ``None``
667668

668-
Return the angle between the line from turtle position to position specified
669-
by (x,y), the vector or the other turtle. This depends on the turtle's start
670-
orientation which depends on the mode - "standard"/"world" or "logo".
669+
Return the angle of the line from the turtle's position to (x,y). If *y* is
670+
``None``, *x* must be a pair of coordinates, a :class:`Vec2D`, for example
671+
as returned by :func:`pos`, or another turtle. The angle is measured from
672+
the turtle's start orientation, which depends on the turtle mode, see
673+
:func:`mode`.
671674

672675
.. doctest::
673676
:skipif: _tkinter is None
@@ -711,8 +714,8 @@ Tell Turtle's state
711714

712715
.. function:: heading()
713716

714-
Return the turtle's current heading (value depends on the turtle mode, see
715-
:func:`mode`).
717+
Return the turtle's current heading. The value depends on the turtle mode,
718+
see :func:`mode`.
716719

717720
.. doctest::
718721
:skipif: _tkinter is None
@@ -728,8 +731,9 @@ Tell Turtle's state
728731
:param x: a number or a pair/vector of numbers or a turtle instance
729732
:param y: a number if *x* is a number, else ``None``
730733

731-
Return the distance from the turtle to (x,y), the given vector, or the given
732-
other turtle, in turtle step units.
734+
Return the distance from the turtle to (x,y) in turtle step units. If *y* is
735+
``None``, *x* must be a pair of coordinates, a :class:`Vec2D`, for example
736+
as returned by :func:`pos`, or another turtle.
733737

734738
.. doctest::
735739
:skipif: _tkinter is None
@@ -752,8 +756,8 @@ Settings for measurement
752756

753757
:param fullcircle: a number
754758

755-
Set angle measurement units, i.e. set number of "degrees" for a full circle.
756-
Default value is 360 degrees.
759+
Set the angle measurement units to degrees. The number of degrees in a full
760+
circle is set to *fullcircle*, which defaults to 360.
757761

758762
.. doctest::
759763
:skipif: _tkinter is None
@@ -776,7 +780,7 @@ Settings for measurement
776780
.. function:: radians()
777781

778782
Set the angle measurement units to radians. Equivalent to
779-
``degrees(2*math.pi)``.
783+
``degrees(2 * math.pi)``.
780784

781785
.. doctest::
782786
:skipif: _tkinter is None

0 commit comments

Comments
 (0)