Skip to content

Commit bdfcfcc

Browse files
committed
New == syntax
1 parent 4d8e859 commit bdfcfcc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+420
-392
lines changed

Demo/scripts/fact.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212

1313
def fact(n):
1414
if n < 1: raise error # fact() argument should be >= 1
15-
if n = 1: return [] # special case
15+
if n == 1: return [] # special case
1616
res = []
1717
# Treat even factors special, so we can use i = i+2 later
18-
while n%2 = 0:
18+
while n%2 == 0:
1919
res.append(2)
2020
n = n/2
2121
# Try odd numbers up to sqrt(n)
2222
limit = sqrt(n+1)
2323
i = 3
2424
while i <= limit:
25-
if n%i = 0:
25+
if n%i == 0:
2626
res.append(i)
2727
n = n/i
2828
limit = sqrt(n+1)

Demo/scripts/from.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
while 1:
2525
line = mail.readline()
2626
if not line: break # EOF
27-
if line[:5] = 'From ':
27+
if line[:5] == 'From ':
2828
# Start of message found
2929
print line[:-1],
3030
while 1:
3131
line = mail.readline()
3232
if not line: break # EOF
33-
if line = '\n': break # Blank line ends headers
34-
if line[:8] = 'Subject:':
33+
if line == '\n': break # Blank line ends headers
34+
if line[:8] == 'Subject:':
3535
print `line[9:-1]`,
3636
print

Demo/scripts/lpwatch.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def main():
2323
# Strip '-P' from printer names just in case
2424
# the user specified it...
2525
for i in range(len(printers)):
26-
if printers[i][:2] = '-P':
26+
if printers[i][:2] == '-P':
2727
printers[i] = printers[i][2:]
2828
else:
2929
if posix.environ.has_key('PRINTER'):
@@ -54,13 +54,13 @@ def makestatus(name, thisuser):
5454
if not line: break
5555
fields = string.split(line)
5656
n = len(fields)
57-
if len(fields) >= 6 and fields[n-1] = 'bytes':
57+
if len(fields) >= 6 and fields[n-1] == 'bytes':
5858
rank = fields[0]
5959
user = fields[1]
6060
job = fields[2]
6161
files = fields[3:-2]
6262
bytes = eval(fields[n-2])
63-
if user = thisuser:
63+
if user == thisuser:
6464
userseen = 1
6565
elif not userseen:
6666
aheadbytes = aheadbytes + bytes
@@ -77,22 +77,22 @@ def makestatus(name, thisuser):
7777
else:
7878
if fields and fields[0] <> 'Rank':
7979
line = string.strip(line)
80-
if line = 'no entries':
80+
if line == 'no entries':
8181
line = name + ': idle'
82-
elif line[-22:] = ' is ready and printing':
82+
elif line[-22:] == ' is ready and printing':
8383
line = name
8484
lines.append(line)
8585
#
8686
if totaljobs:
8787
line = `(totalbytes+1023)/1024` + ' K'
8888
if totaljobs <> len(users):
8989
line = line + ' (' + `totaljobs` + ' jobs)'
90-
if len(users) = 1:
90+
if len(users) == 1:
9191
line = line + ' for ' + users.keys()[0]
9292
else:
9393
line = line + ' for ' + `len(users)` + ' users'
9494
if userseen:
95-
if aheadjobs = 0:
95+
if aheadjobs == 0:
9696
line = line + ' (' + thisuser + ' first)'
9797
else:
9898
line = line + ' (' + `(aheadbytes+1023)/1024`

Demo/scripts/pi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def main():
1919
# Print common digits
2020
d, d1 = a/b, a1/b1
2121
#print a, b, a1, b1
22-
while d = d1:
22+
while d == d1:
2323
# Use write() to avoid spaces between the digits
2424
sys.stdout.write(`int(d)`)
2525
# Flush so the output is seen immediately

Demo/scripts/primes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def primes(min, max):
1717
i = 3
1818
while i <= max:
1919
for p in primes:
20-
if i%p = 0 or p*p > i: break
20+
if i%p == 0 or p*p > i: break
2121
if i%p <> 0:
2222
primes.append(i)
2323
if i >= min: print i

Lib/calendar.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# Return 1 for leap years, 0 for non-leap years
1818
def isleap(year):
19-
return year % 4 = 0 and (year % 100 <> 0 or year % 400 = 0)
19+
return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0)
2020

2121
# Constants for months referenced later
2222
January = 1
@@ -45,7 +45,7 @@ def gmtime(secs):
4545
yday = days
4646
month = January
4747
while 1:
48-
md = mdays[month] + (month = February and isleap(year))
48+
md = mdays[month] + (month == February and isleap(year))
4949
if days < md: break
5050
days = days - md
5151
month = month + 1
@@ -122,7 +122,7 @@ def weekday(year, month, day):
122122
# Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month
123123
def monthrange(year, month):
124124
day1 = weekday(year, month, 1)
125-
ndays = mdays[month] + (month = February and isleap(year))
125+
ndays = mdays[month] + (month == February and isleap(year))
126126
return day1, ndays
127127

128128
# Return a matrix representing a month's calendar
@@ -161,7 +161,7 @@ def center(str, width):
161161
# Print a single week (no newline)
162162
def prweek(week, width):
163163
for day in week:
164-
if day = 0: print ' '*width,
164+
if day == 0: print ' '*width,
165165
else:
166166
if width > 2: print ' '*(width-3),
167167
if day < 10: print '',

Lib/cmp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def cmp(f1, f2): # Compare two files, use the cache if possible.
1919
if s1[0] <> 8 or s2[0] <> 8:
2020
# Either is a not a plain file -- always report as different
2121
return 0
22-
if s1 = s2:
22+
if s1 == s2:
2323
# type, size & mtime match -- report same
2424
return 1
2525
if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
@@ -30,7 +30,7 @@ def cmp(f1, f2): # Compare two files, use the cache if possible.
3030
try:
3131
cs1, cs2, outcome = cache[key]
3232
# cache hit
33-
if s1 = cs1 and s2 = cs2:
33+
if s1 == cs1 and s2 == cs2:
3434
# cached signatures match
3535
return outcome
3636
# stale cached signature(s)

Lib/cmpcache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def cmp(f1, f2):
2929
if not S_ISREG(s1[0]) or not S_ISREG(s2[0]):
3030
# Either is a not a plain file -- always report as different
3131
return 0
32-
if s1 = s2:
32+
if s1 == s2:
3333
# type, size & mtime match -- report same
3434
return 1
3535
if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
@@ -40,7 +40,7 @@ def cmp(f1, f2):
4040
if cache.has_key(key):
4141
cs1, cs2, outcome = cache[key]
4242
# cache hit
43-
if s1 = cs1 and s2 = cs2:
43+
if s1 == cs1 and s2 == cs2:
4444
# cached signatures match
4545
return outcome
4646
# stale cached signature(s)

Lib/commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def getstatusoutput(cmd):
2525
pipe = posix.popen('{ ' + cmd + '; } 2>&1', 'r')
2626
text = pipe.read()
2727
sts = pipe.close()
28-
if sts = None: sts = 0
29-
if text[-1:] = '\n': text = text[:-1]
28+
if sts == None: sts = 0
29+
if text[-1:] == '\n': text = text[:-1]
3030
return sts, text
3131

3232

Lib/dircmp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def cmp(a, b):
174174
#
175175
def remove(list, item):
176176
for i in range(len(list)):
177-
if list[i] = item:
177+
if list[i] == item:
178178
del list[i]
179179
break
180180

0 commit comments

Comments
 (0)