8000 Use random module instead of whrandom · python/cpython@9a62448 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a62448

Browse files
committed
Use random module instead of whrandom
Move imports to top
1 parent 3b2625f commit 9a62448

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Demo/curses/life.py

Lines changed: 4 additions & 4 8000 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# Make board updates faster
1818
#
1919

20+
import random, string, traceback
21+
import curses
22+
2023
class LifeBoard:
2124
"""Encapsulates a Life board
2225
@@ -118,11 +121,10 @@ def display(self, update_board=1):
118121

119122
def makeRandom(self):
120123
"Fill the board with a random pattern"
121-
import whrandom
122124
self.state={}
123125
for i in range(0, self.X):
124126
for j in range(0, self.Y):
125-
if whrandom.random()*10>5.0: self.set(j,i)
127+
if random.random() > 0.5: self.set(j,i)
126128

127129

128130
def erase_menu(stdscr, menu_y):
@@ -139,7 +141,6 @@ def display_menu(stdscr, menu_y):
139141
'E)rase the board, R)andom fill, S)tep once or C)ontinuously, Q)uit')
140142

141143
def main(stdscr):
142-
import string, curses
143144

144145
# Clear the screen and display the menu of keys
145146
stdscr.clear()
@@ -196,7 +197,6 @@ def main(stdscr):
196197
else: pass # Ignore incorrect keys
197198

198199
if __name__=='__main__':
199-
import curses, traceback
200200
try:
201201
# Initialize curses
202202
stdscr=curses.initscr()

0 commit comments

Comments
 (0)
0