Skip to content

Commit 2bcad2f

Browse files
[3.14] gh-157847: Tidy up turtle motion docstrings and docs in turtle module (GH-158330) (#158366)
(cherry picked from commit 6e32490) Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent afc280c commit 2bcad2f

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
@@ -212,7 +212,7 @@ Move and draw
212212
.. function:: forward(distance)
213213
fd(distance)
214214

215-
:param distance: a number (integer or float)
215+
:param distance: a number
216216

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

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

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

261-
:param angle: a number (integer or float)
261+
:param angle: a number
262262

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

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

286-
:param angle: a number (integer or float)
287+
:param angle: a number
287288

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

292294
.. doctest::
293295
:skipif: _tkinter is None
@@ -312,11 +314,10 @@ Move and draw
312314
:param x: a number or a pair/vector of numbers
313315
:param y: a number or ``None``
314316

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

321322
.. doctest::
322323
:skipif: _tkinter is None
@@ -330,13 +331,13 @@ Move and draw
330331
>>> tp = turtle.pos()
331332
>>> tp
332333
(0.00,0.00)
333-
>>> turtle.setpos(60,30)
334+
>>> turtle.goto(60,30)
334335
>>> turtle.pos()
335336
(60.00,30.00)
336-
>>> turtle.setpos((20,80))
337+
>>> turtle.goto((20,80))
337338
>>> turtle.pos()
338339
(20.00,80.00)
339-
>>> turtle.setpos(tp)
340+
>>> turtle.goto(tp)
340341
>>> turtle.pos()
341342
(0.00,0.00)
342343

@@ -381,10 +382,9 @@ Move and draw
381382

382383
.. function:: setx(x)
383384

384-
:param x: a number (integer or float)
385+
:param x: a number
385386

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

389389
.. doctest::
390390
:skipif: _tkinter is None
@@ -404,9 +404,9 @@ Move and draw
404404

405405
.. function:: sety(y)
406406

407-
:param y: a number (integer or float)
407+
:param y: a number
408408

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

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

430-
:param to_angle: a number (integer or float)
430+
:param to_angle: a number
431431

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

435435
=================== ====================
436436
standard mode logo mode
@@ -451,8 +451,9 @@ Move and draw
451451

452452
.. function:: home()
453453

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

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

480481
:param radius: a number
481-
:param extent: a number (or ``None``)
482-
:param steps: an integer (or ``None``)
482+
:param extent: a number or ``None``
483+
:param steps: an integer or ``None``
483484

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

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

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

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

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

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

671674
.. doctest::
672675
:skipif: _tkinter is None
@@ -710,8 +713,8 @@ Tell Turtle's state
710713

711714
.. function:: heading()
712715

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

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

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

733737
.. doctest::
734738
:skipif: _tkinter is None
@@ -751,8 +755,8 @@ Settings for measurement
751755

752756
:param fullcircle: a number
753757

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

757761
.. doctest::
758762
:skipif: _tkinter is None
@@ -775,7 +779,7 @@ Settings for measurement
775779
.. function:: radians()
776780

777781
Set the angle measurement units to radians. Equivalent to
778-
``degrees(2*math.pi)``.
782+
``degrees(2 * math.pi)``.
779783

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

0 commit comments

Comments
 (0)