summaryrefslogtreecommitdiffstats
path: root/Demo/curses/life.py
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-07-17 20:59:35 (GMT)
committerCollin Winter <collinw@gmail.com>2007-07-17 20:59:35 (GMT)
commit6f2df4d5e193d54244b0c2de91ef0ab1604b9243 (patch)
tree5e172400da7561eb4bb8fafc62c8cab511d74dad /Demo/curses/life.py
parenta8c360ee76fb76902a2e2140fbb38d4b06b2d9fb (diff)
downloadcpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.zip
cpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.tar.gz
cpython-6f2df4d5e193d54244b0c2de91ef0ab1604b9243.tar.bz2
Run 2to3 over the Demo/ directory to shut up parse errors from 2to3 about lingering print statements.
Diffstat (limited to 'Demo/curses/life.py')
-rwxr-xr-xDemo/curses/life.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Demo/curses/life.py b/Demo/curses/life.py
index a5bbed2..ec79f9e 100755
--- a/Demo/curses/life.py
+++ b/Demo/curses/life.py
@@ -63,14 +63,14 @@ class LifeBoard:
def set(self, y, x):
"""Set a cell to the live state"""
if x<0 or self.X<=x or y<0 or self.Y<=y:
- raise ValueError, "Coordinates out of range %i,%i"% (y,x)
+ raise ValueError("Coordinates out of range %i,%i"% (y,x))
self.state[x,y] = 1
def toggle(self, y, x):
"""Toggle a cell's state between live and dead"""
if x<0 or self.X<=x or y<0 or self.Y<=y:
- raise ValueError, "Coordinates out of range %i,%i"% (y,x)
- if self.state.has_key( (x,y) ):
+ raise ValueError("Coordinates out of range %i,%i"% (y,x))
+ if (x,y) in self.state:
del self.state[x,y]
self.scr.addch(y+1, x+1, ' ')
else:
@@ -89,7 +89,7 @@ class LifeBoard:
if not update_board:
for i in range(0, M):
for j in range(0, N):
- if self.state.has_key( (i,j) ):
+ if (i,j) in self.state:
self.scr.addch(j+1, i+1, self.char)
else:
self.scr.addch(j+1, i+1, ' ')
@@ -102,10 +102,10 @@ class LifeBoard:
L = range( max(0, i-1), min(M, i+2) )
for j in range(0, N):
s = 0
- live = self.state.has_key( (i,j) )
+ live = (i,j) in self.state
for k in range( max(0, j-1), min(N, j+2) ):
for l in L:
- if self.state.has_key( (l,k) ):
+ if (l,k) in self.state:
s += 1
s -= live
if s == 3: