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
a4aeb336
Commit
a4aeb336
authored
Oct 23, 2019
by
Julin S
Committed by
Raymond Hettinger
Oct 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-38539: Update demo files (GH-16890)
parent
20bf8e08
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
850 additions
and
21 deletions
+850
-21
Tools/demo/README
Tools/demo/README
+13
-13
Tools/demo/hanoi.py
Tools/demo/hanoi.py
+5
-5
Tools/demo/rpythond.py
Tools/demo/rpythond.py
+1
-1
Tools/demo/sortvisu.py
Tools/demo/sortvisu.py
+2
-2
Tools/demo/spreadsheet.py
Tools/demo/spreadsheet.py
+829
-0
No files found.
Tools/demo/README
View file @
a4aeb336
This directory contains a collection of demonstration scripts for
various aspects of Python programming.
beer.py Well-known programming example: Bottles of beer.
eiffel.py Python advanced magic: A metaclass for Eiffel post/preconditions.
hanoi.py Well-known programming example: Towers of Hanoi.
life.py Curses programming: Simple game-of-life.
markov.py Algorithms: Markov chain simulation.
mcast.py Network programming: Send and receive UDP multicast packets.
queens.py Well-known programming example: N-Queens problem.
redemo.py Regular Expressions: GUI script to test regexes.
rpython.py Network programming: Small client for remote code execution.
rpythond.py Network programming: Small server for remote code execution.
sortvisu.py GUI programming: Visualization of different sort algorithms.
ss1.py GUI/Application programming: A simple spreadsheet application.
vector.py Python basics: A vector class with demonstrating special methods.
\ No newline at end of file
beer.py Well-known programming example: Bottles of beer.
eiffel.py Python advanced magic: A metaclass for Eiffel post/preconditions.
hanoi.py Well-known programming example: Towers of Hanoi.
life.py Curses programming: Simple game-of-life.
markov.py Algorithms: Markov chain simulation.
mcast.py Network programming: Send and receive UDP multicast packets.
queens.py Well-known programming example: N-Queens problem.
redemo.py Regular Expressions: GUI script to test regexes.
rpython.py Network programming: Small client for remote code execution.
rpythond.py Network programming: Small server for remote code execution.
sortvisu.py GUI programming: Visualization of different sort algorithms.
spreadsheet.py GUI/Application programming: A simple spreadsheet application.
vector.py Python basics: A vector class demonstrating special methods.
Tools/demo/hanoi.py
View file @
a4aeb336
...
...
@@ -27,7 +27,7 @@ def hanoi(n, a, b, c, report):
class
Tkhanoi
:
# Create our objects
def
__init__
(
self
,
n
,
bitmap
=
None
):
def
__init__
(
self
,
n
,
bitmap
=
None
):
self
.
n
=
n
self
.
tk
=
tk
=
Tk
()
self
.
canvas
=
c
=
Canvas
(
tk
)
...
...
@@ -77,7 +77,7 @@ class Tkhanoi:
# Run -- never returns
def
run
(
self
):
while
1
:
while
True
:
hanoi
(
self
.
n
,
0
,
1
,
2
,
self
.
report
)
hanoi
(
self
.
n
,
1
,
2
,
0
,
self
.
report
)
hanoi
(
self
.
n
,
2
,
0
,
1
,
self
.
report
)
...
...
@@ -94,7 +94,7 @@ class Tkhanoi:
# Lift the piece above peg a
ax1
,
ay1
,
ax2
,
ay2
=
c
.
bbox
(
self
.
pegs
[
a
])
while
1
:
while
True
:
x1
,
y1
,
x2
,
y2
=
c
.
bbox
(
p
)
if
y2
<
ay1
:
break
c
.
move
(
p
,
0
,
-
1
)
...
...
@@ -103,7 +103,7 @@ class Tkhanoi:
# Move it towards peg b
bx1
,
by1
,
bx2
,
by2
=
c
.
bbox
(
self
.
pegs
[
b
])
newcenter
=
(
bx1
+
bx2
)
//
2
while
1
:
while
True
:
x1
,
y1
,
x2
,
y2
=
c
.
bbox
(
p
)
center
=
(
x1
+
x2
)
//
2
if
center
==
newcenter
:
break
...
...
@@ -114,7 +114,7 @@ class Tkhanoi:
# Move it down on top of the previous piece
pieceheight
=
y2
-
y1
newbottom
=
by2
-
pieceheight
*
len
(
self
.
pegstate
[
b
])
-
2
while
1
:
while
True
:
x1
,
y1
,
x2
,
y2
=
c
.
bbox
(
p
)
if
y2
>=
newbottom
:
break
c
.
move
(
p
,
0
,
1
)
...
...
Tools/demo/rpythond.py
View file @
a4aeb336
...
...
@@ -29,7 +29,7 @@ def main():
with
conn
:
print
(
'connection from'
,
remotehost
,
remoteport
)
request
=
b''
while
1
:
while
True
:
data
=
conn
.
recv
(
BUFSIZE
)
if
not
data
:
break
...
...
Tools/demo/sortvisu.py
View file @
a4aeb336
...
...
@@ -444,7 +444,7 @@ def quicksort(array):
array
.
wait
(
1000
)
left
=
first
right
=
last
while
1
:
while
True
:
array
.
message
(
"Sweep right pointer"
)
right
=
right
-
1
array
.
show_right
(
right
)
...
...
@@ -473,7 +473,7 @@ def quicksort(array):
array
.
hide_partition
()
def
demosort
(
array
):
while
1
:
while
True
:
for
alg
in
[
quicksort
,
insertionsort
,
selectionsort
,
bubblesort
]:
randomize
(
array
)
alg
(
array
)
...
...
Tools/demo/spreadsheet.py
0 → 100755
View file @
a4aeb336
This diff is collapsed.
Click to expand it.
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