Skip to content

Commit 18ac992

Browse files
[3.13] gh-157847: Tidy up turtle motion docstrings and docs in turtle module (GH-158330) (#158367)
(cherry picked from commit 6e32490) Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent 9dd852d commit 18ac992

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
@@ -206,7 +206,7 @@ Move and draw
206206
.. function:: forward(distance)
207207
fd(distance)
208208

209-
:param distance: a number (integer or float)
209+
:param distance: a number
210210

211211
Move the turtle forward by the specified *distance*, in the direction the
212212
turtle is headed.
@@ -231,7 +231,7 @@ Move and draw
231231
:param distance: a number
232232

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

236236
.. doctest::
237237
:skipif: _tkinter is None
@@ -252,11 +252,12 @@ Move and draw
252252
.. function:: right(angle)
253253
rt(angle)
254254

255-
:param angle: a number (integer or float)
255+
:param angle: a number
256256

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

261262
.. doctest::
262263
:skipif: _tkinter is None
@@ -277,11 +278,12 @@ Move and draw
277278
.. function:: left(angle)
278279
lt(angle)
279280

280-
:param angle: a number (integer or float)
281+
:param angle: a number
281282

282-
Turn turtle left by *angle* units. (Units are by default degrees, but
283-
can be set via the :func:`degrees` and :func:`radians` functions.) Angle
284-
orientation depends on the turtle mode, see :func:`mode`.
283+
Turn the turtle left by the specified *angle*. The angle is measured in
284+
degrees by default; the unit can be changed with :func:`degrees` or
285+
:func:`radians`. How the heading is measured depends on the turtle mode,
286+
see :func:`mode`.
285287

286288
.. doctest::
287289
:skipif: _tkinter is None
@@ -306,11 +308,10 @@ Move and draw
306308
:param x: a number or a pair/vector of numbers
307309
:param y: a number or ``None``
308310

309-
If *y* is ``None``, *x* must be a pair of coordinates or a :class:`Vec2D`
310-
(e.g. as returned by :func:`pos`).
311-
312-
Move turtle to an absolute position. If the pen is down, draw line. Do
313-
not change the turtle's orientation.
311+
Move the turtle to an absolute position. If *y* is ``None``, *x* must be a
312+
pair of coordinates or a :class:`Vec2D`, for example as returned by
313+
:func:`pos`. If the pen is down, a line is drawn. The turtle's heading does
314+
not change.
314315

315316
.. doctest::
316317
:skipif: _tkinter is None
@@ -324,13 +325,13 @@ Move and draw
324325
>>> tp = turtle.pos()
325326
>>> tp
326327
(0.00,0.00)
327-
>>> turtle.setpos(60,30)
328+
>>> turtle.goto(60,30)
328329
>>> turtle.pos()
329330
(60.00,30.00)
330-
>>> turtle.setpos((20,80))
331+
>>> turtle.goto((20,80))
331332
>>> turtle.pos()
332333
(20.00,80.00)
333-
>>> turtle.setpos(tp)
334+
>>> turtle.goto(tp)
334335
>>> turtle.pos()
335336
(0.00,0.00)
336337

@@ -375,10 +376,9 @@ Move and draw
375376

376377
.. function:: setx(x)
377378

378-
:param x: a number (integer or float)
379+
:param x: a number
379380

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

383383
.. doctest::
384384
:skipif: _tkinter is None
@@ -398,9 +398,9 @@ Move and draw
398398

399399
.. function:: sety(y)
400400

401-
:param y: a number (integer or float)
401+
:param y: a number
402402

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

405405
.. doctest::
406406
:skipif: _tkinter is None
@@ -421,10 +421,10 @@ Move and draw
421421
.. function:: setheading(to_angle)
422422
seth(to_angle)
423423

424-
:param to_angle: a number (integer or float)
424+
:param to_angle: a number
425425

426-
Set the orientation of the turtle to *to_angle*. Here are some common
427-
directions in degrees:
426+
Set the turtle's heading to *to_angle*. Here are some common directions in
427+
degrees:
428428

429429
=================== ====================
430430
standard mode logo mode
@@ -445,8 +445,9 @@ Move and draw
445445

446446
.. function:: home()
447447

448-
Move turtle to the origin -- coordinates (0,0) -- and set its heading to
449-
its start-orientation (which depends on the mode, see :func:`mode`).
448+
Move the turtle to the origin, coordinates (0,0). The turtle's heading is
449+
set to its start orientation, which depends on the turtle mode, see
450+
:func:`mode`.
450451

451452
.. doctest::
452453
:skipif: _tkinter is None
@@ -472,20 +473,20 @@ Move and draw
472473
.. function:: circle(radius, extent=None, steps=None)
473474

474475
:param radius: a number
475-
:param extent: a number (or ``None``)
476-
:param steps: an integer (or ``None``)
476+
:param extent: a number or ``None``
477+
:param steps: an integer or ``None``
477478

478-
Draw a circle with given *radius*. The center is *radius* units left of
479-
the turtle; *extent* -- an angle -- determines which part of the circle
480-
is drawn. If *extent* is not given, draw the entire circle. If *extent*
481-
is not a full circle, one endpoint of the arc is the current pen
482-
position. Draw the arc in counterclockwise direction if *radius* is
483-
positive, otherwise in clockwise direction. Finally the direction of the
484-
turtle is changed by the amount of *extent*.
479+
Draw a circle with the given *radius*. The center is *radius* units left
480+
of the turtle; *extent*, an angle, determines which part of the circle is
481+
drawn. If *extent* is not given, draw the entire circle. If *extent* is
482+
not a full circle, one endpoint of the arc is the current pen position.
483+
Draw the arc in counterclockwise direction if *radius* is positive,
484+
otherwise in clockwise direction. Finally, the turtle's heading is changed
485+
by *extent*.
485486

486487
As the circle is approximated by an inscribed regular polygon, *steps*
487-
determines the number of steps to use. If not given, it will be
488-
calculated automatically. May be used to draw regular polygons.
488+
determines the number of steps to use. If not given, it will be calculated
489+
automatically. May be used to draw regular polygons.
489490

490491
.. doctest::
491492
:skipif: _tkinter is None
@@ -644,7 +645,7 @@ Tell Turtle's state
644645
.. function:: position()
645646
pos()
646647

647-
Return the turtle's current location (x,y) (as a :class:`Vec2D` vector).
648+
Return the turtle's current location (x,y) as a :class:`Vec2D` vector.
648649

649650
.. doctest::
650651
:skipif: _tkinter is None
@@ -658,9 +659,11 @@ Tell Turtle's state
658659
:param x: a number or a pair/vector of numbers or a turtle instance
659660
:param y: a number if *x* is a number, else ``None``
660661

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

665668
.. doctest::
666669
:skipif: _tkinter is None
@@ -704,8 +707,8 @@ Tell Turtle's state
704707

705708
.. function:: heading()
706709

707-
Return the turtle's current heading (value depends on the turtle mode, see
708-
:func:`mode`).
710+
Return the turtle's current heading. The value depends on the turtle mode,
711+
see :func:`mode`.
709712

710713
.. doctest::
711714
:skipif: _tkinter is None
@@ -721,8 +724,9 @@ Tell Turtle's state
721724
:param x: a number or a pair/vector of numbers or a turtle instance
722725
:param y: a number if *x* is a number, else ``None``
723726

724-
Return the distance from the turtle to (x,y), the given vector, or the given
725-
other turtle, in turtle step units.
727+
Return the distance from the turtle to (x,y) in turtle step units. If *y* is
728+
``None``, *x* must be a pair of coordinates, a :class:`Vec2D`, for example
729+
as returned by :func:`pos`, or another turtle.
726730

727731
.. doctest::
728732
:skipif: _tkinter is None
@@ -745,8 +749,8 @@ Settings for measurement
745749

746750
:param fullcircle: a number
747751

748-
Set angle measurement units, i.e. set number of "degrees" for a full circle.
749-
Default value is 360 degrees.
752+
Set the angle measurement units to degrees. The number of degrees in a full
753+
circle is set to *fullcircle*, which defaults to 360.
750754

751755
.. doctest::
752756
:skipif: _tkinter is None
@@ -769,7 +773,7 @@ Settings for measurement
769773
.. function:: radians()
770774

771775
Set the angle measurement units to radians. Equivalent to
772-
``degrees(2*math.pi)``.
776+
``degrees(2 * math.pi)``.
773777

774778
.. doctest::
775779
:skipif: _tkinter is None

0 commit comments

Comments
 (0)