Skip to content

Commit ee251cf

Browse files
Rewrite turtle module docs introduction
1 parent 5962fc2 commit ee251cf

2 files changed

Lines changed: 37 additions & 59 deletions

File tree

‎Doc/includes/optional-module.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ If you are the distributor, see :ref:`optional-module-requirements`.
77
.. Similar notes appear in the docs of the modules:
88
- zipfile
99
- tarfile
10+
- turtle

‎Doc/library/turtle.rst‎

Lines changed: 36 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,6 @@
2424

2525
--------------
2626

27-
Introduction
28-
============
29-
30-
Turtle graphics is an implementation of `the popular geometric drawing tools
31-
introduced in Logo <https://en.wikipedia.org/wiki/Turtle_
32-
(robot)>`_, developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon
33-
in 1967.
34-
35-
.. include:: ../includes/optional-module.rst
36-
37-
38-
Get started
39-
===========
40-
41-
Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it the
42-
command ``turtle.forward(15)``, and it moves (on-screen!) 15 pixels in the
43-
direction it is facing, drawing a line as it moves. Give it the command
44-
``turtle.right(25)``, and it rotates in-place 25 degrees clockwise.
45-
4627
.. sidebar:: Turtle star
4728

4829
Turtle can draw intricate shapes using programs that repeat simple
@@ -51,18 +32,35 @@ direction it is facing, drawing a line as it moves. Give it the command
5132
.. image:: turtle-star.png
5233
:align: center
5334

54-
In Python, turtle graphics provides a representation of a physical "turtle"
55-
(a little robot with a pen) that draws on a sheet of paper on the floor.
35+
Imagine a robotic turtle starting at (0, 0) in the x-y plane.
36+
After an ``import turtle``, give it the command ``turtle.forward(15)``, and it
37+
moves (on-screen!) 15 pixels in the direction it is facing, drawing a line as
38+
it moves. Give it the command ``turtle.right(25)``, and it rotates in-place 25
39+
degrees clockwise.
40+
41+
Turtle graphics is an implementation of `the drawing tools introduced in Logo
42+
<https://en.wikipedia.org/wiki/Turtle_(robot)>`_ in 1967. It was created as an
43+
educational tool, and its instant, visible feedback makes it an effective way
44+
for learners to encounter programming concepts. It is also a convenient way to
45+
produce simple graphical output without bringing in external libraries.
46+
47+
This document includes four main sections:
5648

57-
It's an effective and well-proven way for learners to encounter
58-
programming concepts and interaction with software, as it provides instant,
59-
visible feedback. It also provides convenient access to graphical output
60-
in general.
49+
* :ref:`turtle-tutorial` teaches the basics of turtle drawing.
50+
* :ref:`turtle-reference` describes the functions, methods and classes this
51+
module defines.
52+
* :ref:`turtle-howtos` details how to handle specific tasks.
53+
* :ref:`turtle-explanation` provides background on the object-oriented
54+
interface.
55+
56+
.. note::
6157

62-
Turtle drawing was originally created as an educational tool, to be used by
63-
teachers in the classroom. For the programmer who needs to produce some
64-
graphical output it can be a way to do that without the overhead of
65-
introducing more complex or external libraries into their work.
58+
Turtle graphics requires the :mod:`tkinter` :term:`optional module`.
59+
Installing it is not always straightforward, so check this in advance if
60+
you're planning to use turtle graphics with a learner.
61+
If it is missing from your copy of CPython,
62+
look for documentation from your distributor (that is,
63+
whoever provided Python to you).
6664

6765

6866
.. _turtle-tutorial:
@@ -108,7 +106,8 @@ Notice how the turtle, represented by an arrow, points in different
108106
directions as you steer it.
109107

110108
Experiment with those commands, and also with ``backward()`` and
111-
``right()``.
109+
``right()``. Many commands also have terser aliases, such as ``fd()`` for
110+
:func:`forward`.
112111

113112

114113
Pen control
@@ -188,38 +187,14 @@ Finally, complete the filling::
188187
``end_fill()`` command.)
189188

190189

191-
.. _turtle-how-to:
190+
.. _turtle-howtos:
192191

193-
How to...
194-
=========
192+
How-to guides
193+
=============
195194

196195
This section covers some typical turtle use-cases and approaches.
197196

198197

199-
Get started as quickly as possible
200-
----------------------------------
201-
202-
One of the joys of turtle graphics is the immediate, visual feedback that's
203-
available from simple commands - it's an excellent way to introduce children
204-
to programming ideas, with a minimum of overhead (not just children, of
205-
course).
206-
207-
The turtle module makes this possible by exposing all its basic functionality
208-
as functions, available with ``from turtle import *``. The :ref:`turtle
209-
graphics tutorial <turtle-tutorial>` covers this approach.
210-
211-
It's worth noting that many of the turtle commands also have even more terse
212-
equivalents, such as ``fd()`` for :func:`forward`. These are especially
213-
useful when working with learners for whom typing is not a skill.
214-
215-
.. _note:
216-
217-
You'll need to have the :mod:`Tk interface package <tkinter>` installed on
218-
your system for turtle graphics to work. Be warned that this is not
219-
always straightforward, so check this in advance if you're planning to
220-
use turtle graphics with a learner.
221-
222-
223198
Automatically begin and end filling
224199
-----------------------------------
225200

@@ -323,8 +298,10 @@ The turtle's screen can be customised, for example::
323298
t.screen.bgcolor("orange")
324299

325300

326-
Turtle graphics reference
327-
=========================
301+
.. _turtle-reference:
302+
303+
Reference
304+
=========
328305

329306
.. note::
330307

0 commit comments

Comments
 (0)