Skip to content

Commit a4aeb33

Browse files
ju-shrhettinger
authored andcommitted
bpo-38539: Update demo files (GH-16890)
1 parent 20bf8e0 commit a4aeb33

File tree

5 files changed

+850
-21
lines changed

5 files changed

+850
-21
lines changed

Tools/demo/README

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
This directory contains a collection of demonstration scripts for
22
various aspects of Python programming.
33

4-
beer.py Well-known programming example: Bottles of beer.
5-
eiffel.py Python advanced magic: A metaclass for Eiffel post/preconditions.
6-
hanoi.py Well-known programming example: Towers of Hanoi.
7-
life.py Curses programming: Simple game-of-life.
8-
markov.py Algorithms: Markov chain simulation.
9-
mcast.py Network programming: Send and receive UDP multicast packets.
10-
queens.py Well-known programming example: N-Queens problem.
11-
redemo.py Regular Expressions: GUI script to test regexes.
12-
rpython.py Network programming: Small client for remote code execution.
13-
rpythond.py Network programming: Small server for remote code execution.
14-
sortvisu.py GUI programming: Visualization of different sort algorithms.
15-
ss1.py GUI/Application programming: A simple spreadsheet application.
16-
vector.py Python basics: A vector class with demonstrating special methods.
4+
beer.py Well-known programming example: Bottles of beer.
5+
eiffel.py Python advanced magic: A metaclass for Eiffel post/preconditions.
6+
hanoi.py Well-known programming example: Towers of Hanoi.
7+
life.py Curses programming: Simple game-of-life.
8+
markov.py Algorithms: Markov chain simulation.
9+
mcast.py Network programming: Send and receive UDP multicast packets.
10+
queens.py Well-known programming example: N-Queens problem.
11+
redemo.py Regular Expressions: GUI script to test regexes.
12+
rpython.py Network programming: Small client for remote code execution.
13+
rpythond.py Network programming: Small server for remote code execution.
14+
sortvisu.py GUI programming: Visualization of different sort algorithms.
15+
spreadsheet.py GUI/Application programming: A simple spreadsheet application.
16+
vector.py Python basics: A vector class demonstrating special methods.

Tools/demo/hanoi.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def hanoi(n, a, b, c, report):
2727
class Tkhanoi:
2828

2929
# Create our objects
30-
def __init__(self, n, bitmap = None):
30+
def __init__(self, n, bitmap=None):
3131
self.n = n
3232
self.tk = tk = Tk()
3333
self.canvas = c = Canvas(tk)
@@ -77,7 +77,7 @@ def __init__(self, n, bitmap = None):
7777

7878
# Run -- never returns
7979
def run(self):
80-
while 1:
80+
while True:
8181
hanoi(self.n, 0, 1, 2, self.report)
8282
hanoi(self.n, 1, 2, 0, self.report)
8383
hanoi(self.n, 2, 0, 1, self.report)
@@ -94,7 +94,7 @@ def report(self, i, a, b):
9494

9595
# Lift the piece above peg a
9696
ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a])
97-
while 1:
97+
while True:
9898
x1, y1, x2, y2 = c.bbox(p)
9999
if y2 < ay1: break
100100
c.move(p, 0, -1)
@@ -103,7 +103,7 @@ def report(self, i, a, b):
103103
# Move it towards peg b
104104
bx1, by1, bx2, by2 = c.bbox(self.pegs[b])
105105
newcenter = (bx1+bx2)//2
106-
while 1:
106+
while True:
107107
x1, y1, x2, y2 = c.bbox(p)
108108
center = (x1+x2)//2
109109
if center == newcenter: break
@@ -114,7 +114,7 @@ def report(self, i, a, b):
114114
# Move it down on top of the previous piece
115115
pieceheight = y2-y1
116116
newbottom = by2 - pieceheight*len(self.pegstate[b]) - 2
117-
while 1:
117+
while True:
118118
x1, y1, x2, y2 = c.bbox(p)
119119
if y2 >= newbottom: break
120120
c.move(p, 0, 1)

Tools/demo/rpythond.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def main():
2929
with conn:
3030
print('connection from', remotehost, remoteport)
3131
request = b''
32-
while 1:
32+
while True:
3333
data = conn.recv(BUFSIZE)
3434
if not data:
3535
break

Tools/demo/sortvisu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def quicksort(array):
444444
array.wait(1000)
445445
left = first
446446
right = last
447-
while 1:
447+
while True:
448448
array.message("Sweep right pointer")
449449
right = right-1
450450
array.show_right(right)
@@ -473,7 +473,7 @@ def quicksort(array):
473473
array.hide_partition()
474474

475475
def demosort(array):
476-
while 1:
476+
while True:
477477
for alg in [quicksort, insertionsort, selectionsort, bubblesort]:
478478
randomize(array)
479479
alg(array)

0 commit comments

Comments
 (0)