Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-38539: update demo files #16890

Merged
merged 2 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Tools/demo/README
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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.
beer.py Well-known programming example: Bottles of beer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please undo all the gratuitous whitespace changes and stick with the ones we agreed to.

Copy link
Contributor Author

@ju-sh ju-sh Oct 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhettinger But when ss1.py is renamed to spreadsheet.py in the README, it will touch the next column. How should we go around that?

The original file had 4 spaces between the longest line in the first column and the second column.

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.
10 changes: 5 additions & 5 deletions Tools/demo/hanoi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -77,7 +77,7 @@ def __init__(self, n, bitmap = None):

# 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)
Expand All @@ -94,7 +94,7 @@ def report(self, i, a, b):

# 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)
Expand All @@ -103,7 +103,7 @@ def report(self, i, a, b):
# 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
Expand All @@ -114,7 +114,7 @@ def report(self, i, a, b):
# 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)
Expand Down
2 changes: 1 addition & 1 deletion Tools/demo/rpythond.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Tools/demo/sortvisu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading