cpython: cc559e1e3bd8 (original) (raw)
--- a/Lib/turtle.py +++ b/Lib/turtle.py @@ -905,7 +905,7 @@ class Shape(object): >>> poly = ((0,0),(10,-5),(0,10),(-10,-5)) >>> s = Shape("compound") >>> s.addcomponent(poly, "red", "blue")
### .. add more components and then use register_shape()[](#l1.7)
>>> # .. add more components and then use register_shape()[](#l1.8) """[](#l1.9) if self._type != "compound":[](#l1.10) raise TurtleGraphicsError("Cannot add component to %s Shape"[](#l1.11)
@@ -1003,7 +1003,7 @@ class TurtleScreen(TurtleScreenBase): no backgroundimage, no eventbindings and tracing on. Example (for a TurtleScreen instance named screen):
screen.clear()[](#l1.16)
>>> screen.clear()[](#l1.17)
Note: this method is not available as function. """ @@ -1077,8 +1077,8 @@ class TurtleScreen(TurtleScreenBase): Example (for a TurtleScreen instance named screen): >>> screen.setworldcoordinates(-10,-0.5,50,1.5) >>> for _ in range(36):
left(10)[](#l1.25)
forward(0.5)[](#l1.26)
... left(10)[](#l1.27)
... forward(0.5)[](#l1.28) """[](#l1.29) if self.mode() != "world":[](#l1.30) self.mode("world")[](#l1.31)
@@ -1182,7 +1182,7 @@ class TurtleScreen(TurtleScreenBase): >>> screen.colormode() 1.0 >>> screen.colormode(255)
>>> turtle.pencolor(240,160,80)[](#l1.36)
>>> pencolor(240,160,80)[](#l1.37) """[](#l1.38) if cmode is None:[](#l1.39) return self._colormode[](#l1.40)
@@ -1250,9 +1250,9 @@ class TurtleScreen(TurtleScreenBase): >>> screen.tracer(8, 25) >>> dist = 2 >>> for i in range(200):
fd(dist)[](#l1.45)
rt(90)[](#l1.46)
dist += 2[](#l1.47)
... fd(dist)[](#l1.48)
... rt(90)[](#l1.49)
... dist += 2[](#l1.50) """[](#l1.51) if n is None:[](#l1.52) return self._tracing[](#l1.53)
@@ -1279,7 +1279,7 @@ class TurtleScreen(TurtleScreenBase): self._delayvalue = int(delay) def _incrementudc(self):
"Increment upadate counter."""[](#l1.58)
"""Increment upadate counter."""[](#l1.59) if not TurtleScreen._RUNNING:[](#l1.60) TurtleScreen._RUNNNING = True[](#l1.61) raise Terminator[](#l1.62)
@@ -1347,16 +1347,12 @@ class TurtleScreen(TurtleScreenBase): clicked point on the canvas. num -- the number of the mouse-button, defaults to 1
Example (for a TurtleScreen instance named screen[](#l1.67)
and a Turtle instance named turtle):[](#l1.68)
>>> screen.onclick(turtle.goto)[](#l1.70)
### Subsequently clicking into the TurtleScreen will[](#l1.72)
### make the turtle move to the clicked point.[](#l1.73)
Example (for a TurtleScreen instance named screen)[](#l1.74)
>>> screen.onclick(goto)[](#l1.76)
>>> # Subsequently clicking into the TurtleScreen will[](#l1.77)
>>> # make the turtle move to the clicked point.[](#l1.78) >>> screen.onclick(None)[](#l1.79)
### event-binding will be removed[](#l1.81) """[](#l1.82) self._onscreenclick(fun, btn, add)[](#l1.83)
@@ -1370,20 +1366,18 @@ class TurtleScreen(TurtleScreenBase): In order to be able to register key-events, TurtleScreen must have focus. (See method listen.)
Example (for a TurtleScreen instance named screen[](#l1.89)
and a Turtle instance named turtle):[](#l1.90)
Example (for a TurtleScreen instance named screen):[](#l1.91)
fd(50)[](#l1.94)
lt(60)[](#l1.95)
... fd(50)[](#l1.98)
... lt(60)[](#l1.99)
...[](#l1.100) >>> screen.onkey(f, "Up")[](#l1.101) >>> screen.listen()[](#l1.102)
### Subsequently the turtle can be moved by[](#l1.104)
### repeatedly pressing the up-arrow key,[](#l1.105)
### consequently drawing a hexagon[](#l1.106)
Subsequently the turtle can be moved by repeatedly pressing[](#l1.107)
the up-arrow key, consequently drawing a hexagon[](#l1.108)
+ """ if fun is None: if key in self._keys: @@ -1407,16 +1401,15 @@ class TurtleScreen(TurtleScreenBase): and a Turtle instance named turtle): >>> def f():
fd(50)[](#l1.117)
>>> screen.onkey(f, "Up")[](#l1.120)
... fd(50)[](#l1.121)
... lt(60)[](#l1.122)
...[](#l1.123)
>>> screen.onkeypress(f, "Up")[](#l1.124) >>> screen.listen()[](#l1.125)
### Subsequently the turtle can be moved by[](#l1.127)
### repeatedly pressing the up-arrow key,[](#l1.128)
### or by keeping pressed the up-arrow key.[](#l1.129)
### consequently drawing a hexagon.[](#l1.130)
Subsequently the turtle can be moved by repeatedly pressing[](#l1.131)
the up-arrow key, or by keeping pressed the up-arrow key.[](#l1.132)
consequently drawing a hexagon.[](#l1.133) """[](#l1.134) if fun is None:[](#l1.135) if key in self._keys:[](#l1.136)
@@ -1448,12 +1441,12 @@ class TurtleScreen(TurtleScreenBase): >>> running = True >>> def f():
if running:[](#l1.141)
fd(50)[](#l1.142)
lt(60)[](#l1.143)
screen.ontimer(f, 250)[](#l1.144)
>>> f() ### makes the turtle marching around[](#l1.146)
... if running:[](#l1.147)
... fd(50)[](#l1.148)
... lt(60)[](#l1.149)
... screen.ontimer(f, 250)[](#l1.150)
...[](#l1.151)
>>> f() # makes the turtle marching around[](#l1.152) >>> running = False[](#l1.153) """[](#l1.154) self._ontimer(fun, t)[](#l1.155)
@@ -1497,7 +1490,7 @@ class TurtleScreen(TurtleScreenBase): Example (for a Turtle instance named turtle): >>> turtle.screensize(2000,1500)
### e. g. to search for an erroneously escaped turtle ;-)[](#l1.160)
>>> # e.g. to search for an erroneously escaped turtle ;-)[](#l1.161) """[](#l1.162) return self._resize(canvwidth, canvheight, bg)[](#l1.163)
@@ -2085,7 +2078,7 @@ class TPen(object): Example (for a Turtle instance named turtle): >>> turtle.pensize() 1
turtle.pensize(10) # from here on lines of width 10 are drawn[](#l1.169)
>>> turtle.pensize(10) # from here on lines of width 10 are drawn[](#l1.170) """[](#l1.171) if width is None:[](#l1.172) return self._pensize[](#l1.173)
@@ -2560,7 +2553,7 @@ class RawTurtle(TPen, TNavigator): """Delete the turtle's drawings and restore its default values. No argument. -, + Delete the turtle's drawings from the screen, re-center the turtle and set variables to the default values. @@ -2607,7 +2600,7 @@ class RawTurtle(TPen, TNavigator): Example (for a Turtle instance named turtle): >>> while undobufferentries():
undo()[](#l1.187)
... undo()[](#l1.188) """[](#l1.189) if self.undobuffer is None:[](#l1.190) return 0[](#l1.191)
@@ -2683,9 +2676,9 @@ class RawTurtle(TPen, TNavigator): >>> turtle.tracer(8, 25) >>> dist = 2 >>> for i in range(200):
turtle.fd(dist)[](#l1.196)
turtle.rt(90)[](#l1.197)
dist += 2[](#l1.198)
... turtle.fd(dist)[](#l1.199)
... turtle.rt(90)[](#l1.200)
... dist += 2[](#l1.201) """[](#l1.202) return self.screen.tracer(flag, delay)[](#l1.203)
@@ -2883,7 +2876,6 @@ class RawTurtle(TPen, TNavigator): >>> turtle.shapesize(5,2) >>> turtle.tilt(45) >>> turtle.tiltangle()
>>>[](#l1.209) """[](#l1.210) if angle is None:[](#l1.211) tilt = -self._tilt * (180.0/math.pi) * self._angleOrient[](#l1.212)
@@ -2928,7 +2920,7 @@ class RawTurtle(TPen, TNavigator): >>> turtle.shapesize(4,2) >>> turtle.shearfactor(-0.5) >>> turtle.shapetransform()
>>> (4.0, -1.0, -0.0, 2.0)[](#l1.217)
(4.0, -1.0, -0.0, 2.0)[](#l1.218) """[](#l1.219) if t11 is t12 is t21 is t22 is None:[](#l1.220) return self._shapetrafo[](#l1.221)
@@ -3126,7 +3118,7 @@ class RawTurtle(TPen, TNavigator): Example (for a Turtle instance named turtle): >>> for i in range(8):
turtle.stamp(); turtle.fd(30)[](#l1.226)
... turtle.stamp(); turtle.fd(30)[](#l1.227) ...[](#l1.228) >>> turtle.clearstamps(2)[](#l1.229) >>> turtle.clearstamps(-2)[](#l1.230)
@@ -3302,9 +3294,9 @@ class RawTurtle(TPen, TNavigator): Example (for a Turtle instance named turtle): >>> turtle.begin_fill() >>> if turtle.filling():
turtle.pensize(5)[](#l1.235)
else:[](#l1.236)
turtle.pensize(3)[](#l1.237)
... turtle.pensize(5)[](#l1.238)
... else:[](#l1.239)
... turtle.pensize(3)[](#l1.240) """[](#l1.241) return isinstance(self._fillpath, list)[](#l1.242)
@@ -3534,9 +3526,9 @@ class RawTurtle(TPen, TNavigator): Example for the anonymous turtle, i. e. the procedural way: >>> def turn(x, y):
left(360)[](#l1.248)
>>> onclick(turn) # Now clicking into the turtle will turn it.[](#l1.250)
... left(360)[](#l1.251)
...[](#l1.252)
>>> onclick(turn) # Now clicking into the turtle will turn it.[](#l1.253) >>> onclick(None) # event-binding will be removed[](#l1.254) """[](#l1.255) self.screen._onclick(self.turtle._item, fun, btn, add)[](#l1.256)
@@ -3552,16 +3544,17 @@ class RawTurtle(TPen, TNavigator): Example (for a MyTurtle instance named joe): >>> class MyTurtle(Turtle):
def glow(self,x,y):[](#l1.261)
self.fillcolor("red")[](#l1.262)
def unglow(self,x,y):[](#l1.263)
self.fillcolor("")[](#l1.264)
... def glow(self,x,y):[](#l1.266)
... self.fillcolor("red")[](#l1.267)
... def unglow(self,x,y):[](#l1.268)
... self.fillcolor("")[](#l1.269)
...[](#l1.270) >>> joe = MyTurtle()[](#l1.271) >>> joe.onclick(joe.glow)[](#l1.272) >>> joe.onrelease(joe.unglow)[](#l1.273)
### clicking on joe turns fillcolor red,[](#l1.274)
### unclicking turns it to transparent.[](#l1.275)
Clicking on joe turns fillcolor red, unclicking turns it to[](#l1.277)
transparent.[](#l1.278) """[](#l1.279) self.screen._onrelease(self.turtle._item, fun, btn, add)[](#l1.280) self._update()[](#l1.281)
@@ -3580,9 +3573,9 @@ class RawTurtle(TPen, TNavigator): Example (for a Turtle instance named turtle): >>> turtle.ondrag(turtle.goto)
### Subsequently clicking and dragging a Turtle will[](#l1.286)
### move it across the screen thereby producing handdrawings[](#l1.287)
### (if pen is down).[](#l1.288)
Subsequently clicking and dragging a Turtle will move it[](#l1.289)
across the screen thereby producing handdrawings (if pen is[](#l1.290)
down).[](#l1.291) """[](#l1.292) self.screen._ondrag(self.turtle._item, fun, btn, add)[](#l1.293)
@@ -3630,10 +3623,11 @@ class RawTurtle(TPen, TNavigator): Example (for a Turtle instance named turtle): >>> for i in range(4):
turtle.fd(50); turtle.lt(80)[](#l1.299)
... turtle.fd(50); turtle.lt(80)[](#l1.301)
...[](#l1.302) >>> for i in range(8):[](#l1.303)
turtle.undo()[](#l1.304)
... turtle.undo()[](#l1.305)
...[](#l1.306) """[](#l1.307) if self.undobuffer is None:[](#l1.308) return[](#l1.309)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -87,6 +87,8 @@ Core and Builtins Library ------- +- Issue #13439: Fix many errors in turtle docstrings. +