summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2002-04-10 14:50:16 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2002-04-10 14:50:16 (GMT)
commit9a62448d2f81a9b9f19072fe665732a26a120c58 (patch)
tree99deae79ab530481a167653eb330186ef56538b1
parent3b2625ff82696e01bdec1c9e1bc51369f24bf878 (diff)
downloadcpython-9a62448d2f81a9b9f19072fe665732a26a120c58.zip
cpython-9a62448d2f81a9b9f19072fe665732a26a120c58.tar.gz
cpython-9a62448d2f81a9b9f19072fe665732a26a120c58.tar.bz2
Use random module instead of whrandom
Move imports to top
-rwxr-xr-xDemo/curses/life.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Demo/curses/life.py b/Demo/curses/life.py
index 37d36e8..4ce09d2 100755
--- a/Demo/curses/life.py
+++ b/Demo/curses/life.py
@@ -17,6 +17,9 @@
# Make board updates faster
#
+import random, string, traceback
+import curses
+
class LifeBoard:
"""Encapsulates a Life board
@@ -118,11 +121,10 @@ class LifeBoard:
def makeRandom(self):
"Fill the board with a random pattern"
- import whrandom
self.state={}
for i in range(0, self.X):
for j in range(0, self.Y):
- if whrandom.random()*10>5.0: self.set(j,i)
+ if random.random() > 0.5: self.set(j,i)
def erase_menu(stdscr, menu_y):
@@ -139,7 +141,6 @@ def display_menu(stdscr, menu_y):
'E)rase the board, R)andom fill, S)tep once or C)ontinuously, Q)uit')
def main(stdscr):
- import string, curses
# Clear the screen and display the menu of keys
stdscr.clear()
@@ -196,7 +197,6 @@ def main(stdscr):
else: pass # Ignore incorrect keys
if __name__=='__main__':
- import curses, traceback
try:
# Initialize curses
stdscr=curses.initscr()