Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5645850

Browse files
committed
Issue #13439: Merge branch 3.2
2 parents c42512d + 9aa20af commit 5645850

2 files changed

Lines changed: 65 additions & 69 deletions

File tree

Lib/turtle.py

Lines changed: 63 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ def addcomponent(self, poly, fill, outline=None):
904904
>>> poly = ((0,0),(10,-5),(0,10),(-10,-5))
905905
>>> s = Shape("compound")
906906
>>> s.addcomponent(poly, "red", "blue")
907-
### .. add more components and then use register_shape()
907+
>>> # .. add more components and then use register_shape()
908908
"""
909909
if self._type != "compound":
910910
raise TurtleGraphicsError("Cannot add component to %s Shape"
@@ -1002,7 +1002,7 @@ def clear(self):
10021002
no backgroundimage, no eventbindings and tracing on.
10031003
10041004
Example (for a TurtleScreen instance named screen):
1005-
screen.clear()
1005+
>>> screen.clear()
10061006
10071007
Note: this method is not available as function.
10081008
"""
@@ -1076,8 +1076,8 @@ def setworldcoordinates(self, llx, lly, urx, ury):
10761076
Example (for a TurtleScreen instance named screen):
10771077
>>> screen.setworldcoordinates(-10,-0.5,50,1.5)
10781078
>>> for _ in range(36):
1079-
left(10)
1080-
forward(0.5)
1079+
... left(10)
1080+
... forward(0.5)
10811081
"""
10821082
if self.mode() != "world":
10831083
self.mode("world")
@@ -1181,7 +1181,7 @@ def colormode(self, cmode=None):
11811181
>>> screen.colormode()
11821182
1.0
11831183
>>> screen.colormode(255)
1184-
>>> turtle.pencolor(240,160,80)
1184+
>>> pencolor(240,160,80)
11851185
"""
11861186
if cmode is None:
11871187
return self._colormode
@@ -1249,9 +1249,9 @@ def tracer(self, n=None, delay=None):
12491249
>>> screen.tracer(8, 25)
12501250
>>> dist = 2
12511251
>>> for i in range(200):
1252-
fd(dist)
1253-
rt(90)
1254-
dist += 2
1252+
... fd(dist)
1253+
... rt(90)
1254+
... dist += 2
12551255
"""
12561256
if n is None:
12571257
return self._tracing
@@ -1278,7 +1278,7 @@ def delay(self, delay=None):
12781278
self._delayvalue = int(delay)
12791279

12801280
def _incrementudc(self):
1281-
"Increment upadate counter."""
1281+
"""Increment upadate counter."""
12821282
if not TurtleScreen._RUNNING:
12831283
TurtleScreen._RUNNNING = True
12841284
raise Terminator
@@ -1346,16 +1346,12 @@ def onclick(self, fun, btn=1, add=None):
13461346
clicked point on the canvas.
13471347
num -- the number of the mouse-button, defaults to 1
13481348
1349-
Example (for a TurtleScreen instance named screen
1350-
and a Turtle instance named turtle):
1349+
Example (for a TurtleScreen instance named screen)
13511350
1352-
>>> screen.onclick(turtle.goto)
1353-
1354-
### Subsequently clicking into the TurtleScreen will
1355-
### make the turtle move to the clicked point.
1351+
>>> screen.onclick(goto)
1352+
>>> # Subsequently clicking into the TurtleScreen will
1353+
>>> # make the turtle move to the clicked point.
13561354
>>> screen.onclick(None)
1357-
1358-
### event-binding will be removed
13591355
"""
13601356
self._onscreenclick(fun, btn, add)
13611357

@@ -1369,20 +1365,18 @@ def onkey(self, fun, key):
13691365
In order to be able to register key-events, TurtleScreen
13701366
must have focus. (See method listen.)
13711367
1372-
Example (for a TurtleScreen instance named screen
1373-
and a Turtle instance named turtle):
1368+
Example (for a TurtleScreen instance named screen):
13741369
13751370
>>> def f():
1376-
fd(50)
1377-
lt(60)
1378-
1379-
1371+
... fd(50)
1372+
... lt(60)
1373+
...
13801374
>>> screen.onkey(f, "Up")
13811375
>>> screen.listen()
13821376
1383-
### Subsequently the turtle can be moved by
1384-
### repeatedly pressing the up-arrow key,
1385-
### consequently drawing a hexagon
1377+
Subsequently the turtle can be moved by repeatedly pressing
1378+
the up-arrow key, consequently drawing a hexagon
1379+
13861380
"""
13871381
if fun is None:
13881382
if key in self._keys:
@@ -1406,16 +1400,15 @@ def onkeypress(self, fun, key=None):
14061400
and a Turtle instance named turtle):
14071401
14081402
>>> def f():
1409-
fd(50)
1410-
1411-
1412-
>>> screen.onkey(f, "Up")
1403+
... fd(50)
1404+
... lt(60)
1405+
...
1406+
>>> screen.onkeypress(f, "Up")
14131407
>>> screen.listen()
14141408
1415-
### Subsequently the turtle can be moved by
1416-
### repeatedly pressing the up-arrow key,
1417-
### or by keeping pressed the up-arrow key.
1418-
### consequently drawing a hexagon.
1409+
Subsequently the turtle can be moved by repeatedly pressing
1410+
the up-arrow key, or by keeping pressed the up-arrow key.
1411+
consequently drawing a hexagon.
14191412
"""
14201413
if fun is None:
14211414
if key in self._keys:
@@ -1447,12 +1440,12 @@ def ontimer(self, fun, t=0):
14471440
14481441
>>> running = True
14491442
>>> def f():
1450-
if running:
1451-
fd(50)
1452-
lt(60)
1453-
screen.ontimer(f, 250)
1454-
1455-
>>> f() ### makes the turtle marching around
1443+
... if running:
1444+
... fd(50)
1445+
... lt(60)
1446+
... screen.ontimer(f, 250)
1447+
...
1448+
>>> f() # makes the turtle marching around
14561449
>>> running = False
14571450
"""
14581451
self._ontimer(fun, t)
@@ -1496,7 +1489,7 @@ def screensize(self, canvwidth=None, canvheight=None, bg=None):
14961489
14971490
Example (for a Turtle instance named turtle):
14981491
>>> turtle.screensize(2000,1500)
1499-
### e. g. to search for an erroneously escaped turtle ;-)
1492+
>>> # e.g. to search for an erroneously escaped turtle ;-)
15001493
"""
15011494
return self._resize(canvwidth, canvheight, bg)
15021495

@@ -2084,7 +2077,7 @@ def pensize(self, width=None):
20842077
Example (for a Turtle instance named turtle):
20852078
>>> turtle.pensize()
20862079
1
2087-
turtle.pensize(10) # from here on lines of width 10 are drawn
2080+
>>> turtle.pensize(10) # from here on lines of width 10 are drawn
20882081
"""
20892082
if width is None:
20902083
return self._pensize
@@ -2559,7 +2552,7 @@ def reset(self):
25592552
"""Delete the turtle's drawings and restore its default values.
25602553
25612554
No argument.
2562-
,
2555+
25632556
Delete the turtle's drawings from the screen, re-center the turtle
25642557
and set variables to the default values.
25652558
@@ -2606,7 +2599,7 @@ def undobufferentries(self):
26062599
26072600
Example (for a Turtle instance named turtle):
26082601
>>> while undobufferentries():
2609-
undo()
2602+
... undo()
26102603
"""
26112604
if self.undobuffer is None:
26122605
return 0
@@ -2682,9 +2675,9 @@ def _tracer(self, flag=None, delay=None):
26822675
>>> turtle.tracer(8, 25)
26832676
>>> dist = 2
26842677
>>> for i in range(200):
2685-
turtle.fd(dist)
2686-
turtle.rt(90)
2687-
dist += 2
2678+
... turtle.fd(dist)
2679+
... turtle.rt(90)
2680+
... dist += 2
26882681
"""
26892682
return self.screen.tracer(flag, delay)
26902683

@@ -2882,7 +2875,6 @@ def tiltangle(self, angle=None):
28822875
>>> turtle.shapesize(5,2)
28832876
>>> turtle.tilt(45)
28842877
>>> turtle.tiltangle()
2885-
>>>
28862878
"""
28872879
if angle is None:
28882880
tilt = -self._tilt * (180.0/math.pi) * self._angleOrient
@@ -2927,7 +2919,7 @@ def shapetransform(self, t11=None, t12=None, t21=None, t22=None):
29272919
>>> turtle.shapesize(4,2)
29282920
>>> turtle.shearfactor(-0.5)
29292921
>>> turtle.shapetransform()
2930-
>>> (4.0, -1.0, -0.0, 2.0)
2922+
(4.0, -1.0, -0.0, 2.0)
29312923
"""
29322924
if t11 is t12 is t21 is t22 is None:
29332925
return self._shapetrafo
@@ -3125,7 +3117,7 @@ def clearstamps(self, n=None):
31253117
31263118
Example (for a Turtle instance named turtle):
31273119
>>> for i in range(8):
3128-
turtle.stamp(); turtle.fd(30)
3120+
... turtle.stamp(); turtle.fd(30)
31293121
...
31303122
>>> turtle.clearstamps(2)
31313123
>>> turtle.clearstamps(-2)
@@ -3301,9 +3293,9 @@ def filling(self):
33013293
Example (for a Turtle instance named turtle):
33023294
>>> turtle.begin_fill()
33033295
>>> if turtle.filling():
3304-
turtle.pensize(5)
3305-
else:
3306-
turtle.pensize(3)
3296+
... turtle.pensize(5)
3297+
... else:
3298+
... turtle.pensize(3)
33073299
"""
33083300
return isinstance(self._fillpath, list)
33093301

@@ -3533,9 +3525,9 @@ def onclick(self, fun, btn=1, add=None):
35333525
Example for the anonymous turtle, i. e. the procedural way:
35343526
35353527
>>> def turn(x, y):
3536-
left(360)
3537-
3538-
>>> onclick(turn) # Now clicking into the turtle will turn it.
3528+
... left(360)
3529+
...
3530+
>>> onclick(turn) # Now clicking into the turtle will turn it.
35393531
>>> onclick(None) # event-binding will be removed
35403532
"""
35413533
self.screen._onclick(self.turtle._item, fun, btn, add)
@@ -3551,16 +3543,17 @@ def onrelease(self, fun, btn=1, add=None):
35513543
35523544
Example (for a MyTurtle instance named joe):
35533545
>>> class MyTurtle(Turtle):
3554-
def glow(self,x,y):
3555-
self.fillcolor("red")
3556-
def unglow(self,x,y):
3557-
self.fillcolor("")
3558-
3546+
... def glow(self,x,y):
3547+
... self.fillcolor("red")
3548+
... def unglow(self,x,y):
3549+
... self.fillcolor("")
3550+
...
35593551
>>> joe = MyTurtle()
35603552
>>> joe.onclick(joe.glow)
35613553
>>> joe.onrelease(joe.unglow)
3562-
### clicking on joe turns fillcolor red,
3563-
### unclicking turns it to transparent.
3554+
3555+
Clicking on joe turns fillcolor red, unclicking turns it to
3556+
transparent.
35643557
"""
35653558
self.screen._onrelease(self.turtle._item, fun, btn, add)
35663559
self._update()
@@ -3579,9 +3572,9 @@ def ondrag(self, fun, btn=1, add=None):
35793572
Example (for a Turtle instance named turtle):
35803573
>>> turtle.ondrag(turtle.goto)
35813574
3582-
### Subsequently clicking and dragging a Turtle will
3583-
### move it across the screen thereby producing handdrawings
3584-
### (if pen is down).
3575+
Subsequently clicking and dragging a Turtle will move it
3576+
across the screen thereby producing handdrawings (if pen is
3577+
down).
35853578
"""
35863579
self.screen._ondrag(self.turtle._item, fun, btn, add)
35873580

@@ -3629,10 +3622,11 @@ def undo(self):
36293622
36303623
Example (for a Turtle instance named turtle):
36313624
>>> for i in range(4):
3632-
turtle.fd(50); turtle.lt(80)
3633-
3625+
... turtle.fd(50); turtle.lt(80)
3626+
...
36343627
>>> for i in range(8):
3635-
turtle.undo()
3628+
... turtle.undo()
3629+
...
36363630
"""
36373631
if self.undobuffer is None:
36383632
return

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ Core and Builtins
399399
Library
400400
-------
401401

402+
- Issue #13439: Fix many errors in turtle docstrings.
403+
402404
- Issue #6715: Add a module 'lzma' for compression using the LZMA algorithm.
403405
Thanks to Per Øyvind Karlsen for the initial implementation.
404406

0 commit comments

Comments
 (0)