Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c2272e30
Commit
c2272e30
authored
Dec 02, 2011
by
Petri Lehtinen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #13439: Fix many errors in turtle docstrings.
parent
98ce5b56
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
54 deletions
+52
-54
Lib/lib-tk/turtle.py
Lib/lib-tk/turtle.py
+50
-54
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/lib-tk/turtle.py
View file @
c2272e30
...
@@ -859,7 +859,7 @@ class Shape(object):
...
@@ -859,7 +859,7 @@ class Shape(object):
>>> poly = ((0,0),(10,-5),(0,10),(-10,-5))
>>> poly = ((0,0),(10,-5),(0,10),(-10,-5))
>>> s = Shape("compound")
>>> s = Shape("compound")
>>> s.addcomponent(poly, "red", "blue")
>>> s.addcomponent(poly, "red", "blue")
##
# .. add more components and then use register_shape()
>>>
# .. add more components and then use register_shape()
"""
"""
if
self
.
_type
!=
"compound"
:
if
self
.
_type
!=
"compound"
:
raise
TurtleGraphicsError
(
"Cannot add component to %s Shape"
raise
TurtleGraphicsError
(
"Cannot add component to %s Shape"
...
@@ -958,7 +958,7 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -958,7 +958,7 @@ class TurtleScreen(TurtleScreenBase):
No argument.
No argument.
Example (for a TurtleScreen instance named screen):
Example (for a TurtleScreen instance named screen):
screen.clear()
>>>
screen.clear()
Note: this method is not available as function.
Note: this method is not available as function.
"""
"""
...
@@ -1030,8 +1030,8 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1030,8 +1030,8 @@ class TurtleScreen(TurtleScreenBase):
Example (for a TurtleScreen instance named screen):
Example (for a TurtleScreen instance named screen):
>>> screen.setworldcoordinates(-10,-0.5,50,1.5)
>>> screen.setworldcoordinates(-10,-0.5,50,1.5)
>>> for _ in range(36):
>>> for _ in range(36):
left(10)
...
left(10)
forward(0.5)
...
forward(0.5)
"""
"""
if
self
.
mode
()
!=
"world"
:
if
self
.
mode
()
!=
"world"
:
self
.
mode
(
"world"
)
self
.
mode
(
"world"
)
...
@@ -1136,7 +1136,7 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1136,7 +1136,7 @@ class TurtleScreen(TurtleScreenBase):
>>> screen.colormode()
>>> screen.colormode()
1.0
1.0
>>> screen.colormode(255)
>>> screen.colormode(255)
>>>
turtle.
pencolor(240,160,80)
>>> pencolor(240,160,80)
"""
"""
if
cmode
is
None
:
if
cmode
is
None
:
return
self
.
_colormode
return
self
.
_colormode
...
@@ -1204,9 +1204,9 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1204,9 +1204,9 @@ class TurtleScreen(TurtleScreenBase):
>>> screen.tracer(8, 25)
>>> screen.tracer(8, 25)
>>> dist = 2
>>> dist = 2
>>> for i in range(200):
>>> for i in range(200):
fd(dist)
...
fd(dist)
rt(90)
...
rt(90)
dist += 2
...
dist += 2
"""
"""
if
n
is
None
:
if
n
is
None
:
return
self
.
_tracing
return
self
.
_tracing
...
@@ -1233,7 +1233,7 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1233,7 +1233,7 @@ class TurtleScreen(TurtleScreenBase):
self
.
_delayvalue
=
int
(
delay
)
self
.
_delayvalue
=
int
(
delay
)
def
_incrementudc
(
self
):
def
_incrementudc
(
self
):
"Increment upadate counter."""
"
""
Increment upadate counter."""
if
not
TurtleScreen
.
_RUNNING
:
if
not
TurtleScreen
.
_RUNNING
:
TurtleScreen
.
_RUNNNING
=
True
TurtleScreen
.
_RUNNNING
=
True
raise
Terminator
raise
Terminator
...
@@ -1304,13 +1304,10 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1304,13 +1304,10 @@ class TurtleScreen(TurtleScreenBase):
Example (for a TurtleScreen instance named screen
Example (for a TurtleScreen instance named screen
and a Turtle instance named turtle):
and a Turtle instance named turtle):
>>> screen.onclick(turtle.goto)
>>> screen.onclick(goto)
>>> # Subsequently clicking into the TurtleScreen will
### Subsequently clicking into the TurtleScreen will
>>> # make the turtle move to the clicked point.
### make the turtle move to the clicked point.
>>> screen.onclick(None)
>>> screen.onclick(None)
### event-binding will be removed
"""
"""
self
.
_onscreenclick
(
fun
,
btn
,
add
)
self
.
_onscreenclick
(
fun
,
btn
,
add
)
...
@@ -1324,20 +1321,18 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1324,20 +1321,18 @@ class TurtleScreen(TurtleScreenBase):
In order to be able to register key-events, TurtleScreen
In order to be able to register key-events, TurtleScreen
must have focus. (See method listen.)
must have focus. (See method listen.)
Example (for a TurtleScreen instance named screen
Example (for a TurtleScreen instance named screen):
and a Turtle instance named turtle):
>>> def f():
>>> def f():
fd(50)
... fd(50)
lt(60)
... lt(60)
...
>>> screen.onkey(f, "Up")
>>> screen.onkey(f, "Up")
>>> screen.listen()
>>> screen.listen()
### Subsequently the turtle can be moved by
Subsequently the turtle can be moved by repeatedly pressing
### repeatedly pressing the up-arrow key,
the up-arrow key, consequently drawing a hexagon
### consequently drawing a hexagon
"""
"""
if
fun
is
None
:
if
fun
is
None
:
if
key
in
self
.
_keys
:
if
key
in
self
.
_keys
:
...
@@ -1369,12 +1364,12 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1369,12 +1364,12 @@ class TurtleScreen(TurtleScreenBase):
>>> running = True
>>> running = True
>>> def f():
>>> def f():
if running:
...
if running:
fd(50)
...
fd(50)
lt(60)
...
lt(60)
screen.ontimer(f, 250)
...
screen.ontimer(f, 250)
...
>>> f() #
##
makes the turtle marching around
>>> f() # makes the turtle marching around
>>> running = False
>>> running = False
"""
"""
self
.
_ontimer
(
fun
,
t
)
self
.
_ontimer
(
fun
,
t
)
...
@@ -1418,7 +1413,7 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1418,7 +1413,7 @@ class TurtleScreen(TurtleScreenBase):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> turtle.screensize(2000,1500)
>>> turtle.screensize(2000,1500)
##
# e. g. to search for an erroneously escaped turtle ;-)
>>>
# e. g. to search for an erroneously escaped turtle ;-)
"""
"""
return
self
.
_resize
(
canvwidth
,
canvheight
,
bg
)
return
self
.
_resize
(
canvwidth
,
canvheight
,
bg
)
...
@@ -2004,7 +1999,7 @@ class TPen(object):
...
@@ -2004,7 +1999,7 @@ class TPen(object):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> turtle.pensize()
>>> turtle.pensize()
1
1
turtle.pensize(10) # from here on lines of width 10 are drawn
>>>
turtle.pensize(10) # from here on lines of width 10 are drawn
"""
"""
if
width
is
None
:
if
width
is
None
:
return
self
.
_pensize
return
self
.
_pensize
...
@@ -2516,7 +2511,7 @@ class RawTurtle(TPen, TNavigator):
...
@@ -2516,7 +2511,7 @@ class RawTurtle(TPen, TNavigator):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> while undobufferentries():
>>> while undobufferentries():
undo()
...
undo()
"""
"""
if
self
.
undobuffer
is
None
:
if
self
.
undobuffer
is
None
:
return
0
return
0
...
@@ -2592,9 +2587,9 @@ class RawTurtle(TPen, TNavigator):
...
@@ -2592,9 +2587,9 @@ class RawTurtle(TPen, TNavigator):
>>> turtle.tracer(8, 25)
>>> turtle.tracer(8, 25)
>>> dist = 2
>>> dist = 2
>>> for i in range(200):
>>> for i in range(200):
turtle.fd(dist)
...
turtle.fd(dist)
turtle.rt(90)
...
turtle.rt(90)
dist += 2
...
dist += 2
"""
"""
return
self
.
screen
.
tracer
(
flag
,
delay
)
return
self
.
screen
.
tracer
(
flag
,
delay
)
...
@@ -2763,7 +2758,6 @@ class RawTurtle(TPen, TNavigator):
...
@@ -2763,7 +2758,6 @@ class RawTurtle(TPen, TNavigator):
>>> turtle.shapesize(5,2)
>>> turtle.shapesize(5,2)
>>> turtle.tilt(45)
>>> turtle.tilt(45)
>>> turtle.tiltangle()
>>> turtle.tiltangle()
>>>
"""
"""
tilt
=
-
self
.
_tilt
*
(
180.0
/
math
.
pi
)
*
self
.
_angleOrient
tilt
=
-
self
.
_tilt
*
(
180.0
/
math
.
pi
)
*
self
.
_angleOrient
return
(
tilt
/
self
.
_degreesPerAU
)
%
self
.
_fullcircle
return
(
tilt
/
self
.
_degreesPerAU
)
%
self
.
_fullcircle
...
@@ -2963,7 +2957,7 @@ class RawTurtle(TPen, TNavigator):
...
@@ -2963,7 +2957,7 @@ class RawTurtle(TPen, TNavigator):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> for i in range(8):
>>> for i in range(8):
turtle.stamp(); turtle.fd(30)
...
turtle.stamp(); turtle.fd(30)
...
...
>>> turtle.clearstamps(2)
>>> turtle.clearstamps(2)
>>> turtle.clearstamps(-2)
>>> turtle.clearstamps(-2)
...
@@ -3430,9 +3424,9 @@ class RawTurtle(TPen, TNavigator):
...
@@ -3430,9 +3424,9 @@ class RawTurtle(TPen, TNavigator):
Example for the anonymous turtle, i. e. the procedural way:
Example for the anonymous turtle, i. e. the procedural way:
>>> def turn(x, y):
>>> def turn(x, y):
left(360)
...
left(360)
...
>>> onclick(turn) # Now clicking into the turtle will turn it.
>>> onclick(turn)
# Now clicking into the turtle will turn it.
>>> onclick(None) # event-binding will be removed
>>> onclick(None) # event-binding will be removed
"""
"""
self
.
screen
.
_onclick
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
self
.
screen
.
_onclick
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
...
@@ -3448,16 +3442,17 @@ class RawTurtle(TPen, TNavigator):
...
@@ -3448,16 +3442,17 @@ class RawTurtle(TPen, TNavigator):
Example (for a MyTurtle instance named joe):
Example (for a MyTurtle instance named joe):
>>> class MyTurtle(Turtle):
>>> class MyTurtle(Turtle):
def glow(self,x,y):
...
def glow(self,x,y):
self.fillcolor("red")
...
self.fillcolor("red")
def unglow(self,x,y):
...
def unglow(self,x,y):
self.fillcolor("")
...
self.fillcolor("")
...
>>> joe = MyTurtle()
>>> joe = MyTurtle()
>>> joe.onclick(joe.glow)
>>> joe.onclick(joe.glow)
>>> joe.onrelease(joe.unglow)
>>> joe.onrelease(joe.unglow)
### clicking on joe turns fillcolor red,
### unclicking turns it to transparent.
Clicking on joe turns fillcolor red, unclicking turns it to
transparent.
"""
"""
self
.
screen
.
_onrelease
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
self
.
screen
.
_onrelease
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
self
.
_update
()
self
.
_update
()
...
@@ -3476,9 +3471,9 @@ class RawTurtle(TPen, TNavigator):
...
@@ -3476,9 +3471,9 @@ class RawTurtle(TPen, TNavigator):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> turtle.ondrag(turtle.goto)
>>> turtle.ondrag(turtle.goto)
### Subsequently clicking and dragging a Turtle will
Subsequently clicking and dragging a Turtle will move it
### move it across the screen thereby producing handdrawing
s
across the screen thereby producing handdrawings (if pen i
s
### (if pen is
down).
down).
"""
"""
self
.
screen
.
_ondrag
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
self
.
screen
.
_ondrag
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
...
@@ -3525,10 +3520,11 @@ class RawTurtle(TPen, TNavigator):
...
@@ -3525,10 +3520,11 @@ class RawTurtle(TPen, TNavigator):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> for i in range(4):
>>> for i in range(4):
turtle.fd(50); turtle.lt(80)
...
turtle.fd(50); turtle.lt(80)
...
>>> for i in range(8):
>>> for i in range(8):
turtle.undo()
... turtle.undo()
...
"""
"""
if
self
.
undobuffer
is
None
:
if
self
.
undobuffer
is
None
:
return
return
...
...
Misc/NEWS
View file @
c2272e30
...
@@ -79,6 +79,8 @@ Core and Builtins
...
@@ -79,6 +79,8 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
13439
:
Fix
many
errors
in
turtle
docstrings
.
-
Issue
#
12856
:
Ensure
child
processes
do
not
inherit
the
parent
's random
-
Issue
#
12856
:
Ensure
child
processes
do
not
inherit
the
parent
's random
seed for filename generation in the tempfile module. Patch by Brian
seed for filename generation in the tempfile module. Patch by Brian
Harring.
Harring.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment