diff options
author | Guido van Rossum <guido@python.org> | 1992-01-01 19:35:13 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-01-01 19:35:13 (GMT) |
commit | bdfcfccbe591e15221f35add01132174c9b4e669 (patch) | |
tree | 7e5f0d52b8c44e623b12e8f4b5cd645c361e5aeb | |
parent | 4d8e859e8f0a209a7e999ce9cc0988156c795949 (diff) | |
download | cpython-bdfcfccbe591e15221f35add01132174c9b4e669.zip cpython-bdfcfccbe591e15221f35add01132174c9b4e669.tar.gz cpython-bdfcfccbe591e15221f35add01132174c9b4e669.tar.bz2 |
New == syntax
73 files changed, 420 insertions, 392 deletions
diff --git a/Demo/scripts/fact.py b/Demo/scripts/fact.py index 6aac414..b406086 100755 --- a/Demo/scripts/fact.py +++ b/Demo/scripts/fact.py @@ -12,17 +12,17 @@ error = 'fact.error' # exception def fact(n): if n < 1: raise error # fact() argument should be >= 1 - if n = 1: return [] # special case + if n == 1: return [] # special case res = [] # Treat even factors special, so we can use i = i+2 later - while n%2 = 0: + while n%2 == 0: res.append(2) n = n/2 # Try odd numbers up to sqrt(n) limit = sqrt(n+1) i = 3 while i <= limit: - if n%i = 0: + if n%i == 0: res.append(i) n = n/i limit = sqrt(n+1) diff --git a/Demo/scripts/from.py b/Demo/scripts/from.py index 21ca081..8e663f1 100755 --- a/Demo/scripts/from.py +++ b/Demo/scripts/from.py @@ -24,13 +24,13 @@ except RuntimeError: while 1: line = mail.readline() if not line: break # EOF - if line[:5] = 'From ': + if line[:5] == 'From ': # Start of message found print line[:-1], while 1: line = mail.readline() if not line: break # EOF - if line = '\n': break # Blank line ends headers - if line[:8] = 'Subject:': + if line == '\n': break # Blank line ends headers + if line[:8] == 'Subject:': print `line[9:-1]`, print diff --git a/Demo/scripts/lpwatch.py b/Demo/scripts/lpwatch.py index db0f469..afd46f3 100755 --- a/Demo/scripts/lpwatch.py +++ b/Demo/scripts/lpwatch.py @@ -23,7 +23,7 @@ def main(): # Strip '-P' from printer names just in case # the user specified it... for i in range(len(printers)): - if printers[i][:2] = '-P': + if printers[i][:2] == '-P': printers[i] = printers[i][2:] else: if posix.environ.has_key('PRINTER'): @@ -54,13 +54,13 @@ def makestatus(name, thisuser): if not line: break fields = string.split(line) n = len(fields) - if len(fields) >= 6 and fields[n-1] = 'bytes': + if len(fields) >= 6 and fields[n-1] == 'bytes': rank = fields[0] user = fields[1] job = fields[2] files = fields[3:-2] bytes = eval(fields[n-2]) - if user = thisuser: + if user == thisuser: userseen = 1 elif not userseen: aheadbytes = aheadbytes + bytes @@ -77,9 +77,9 @@ def makestatus(name, thisuser): else: if fields and fields[0] <> 'Rank': line = string.strip(line) - if line = 'no entries': + if line == 'no entries': line = name + ': idle' - elif line[-22:] = ' is ready and printing': + elif line[-22:] == ' is ready and printing': line = name lines.append(line) # @@ -87,12 +87,12 @@ def makestatus(name, thisuser): line = `(totalbytes+1023)/1024` + ' K' if totaljobs <> len(users): line = line + ' (' + `totaljobs` + ' jobs)' - if len(users) = 1: + if len(users) == 1: line = line + ' for ' + users.keys()[0] else: line = line + ' for ' + `len(users)` + ' users' if userseen: - if aheadjobs = 0: + if aheadjobs == 0: line = line + ' (' + thisuser + ' first)' else: line = line + ' (' + `(aheadbytes+1023)/1024` diff --git a/Demo/scripts/pi.py b/Demo/scripts/pi.py index 5e19db6..74a66a7 100755 --- a/Demo/scripts/pi.py +++ b/Demo/scripts/pi.py @@ -19,7 +19,7 @@ def main(): # Print common digits d, d1 = a/b, a1/b1 #print a, b, a1, b1 - while d = d1: + while d == d1: # Use write() to avoid spaces between the digits sys.stdout.write(`int(d)`) # Flush so the output is seen immediately diff --git a/Demo/scripts/primes.py b/Demo/scripts/primes.py index 487acef..6a36d6e 100755 --- a/Demo/scripts/primes.py +++ b/Demo/scripts/primes.py @@ -17,7 +17,7 @@ def primes(min, max): i = 3 while i <= max: for p in primes: - if i%p = 0 or p*p > i: break + if i%p == 0 or p*p > i: break if i%p <> 0: primes.append(i) if i >= min: print i diff --git a/Lib/calendar.py b/Lib/calendar.py index ee16c76..f00268b 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -16,7 +16,7 @@ day_0 = 3 # The epoch begins on a Thursday (Monday = 0) # Return 1 for leap years, 0 for non-leap years def isleap(year): - return year % 4 = 0 and (year % 100 <> 0 or year % 400 = 0) + return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0) # Constants for months referenced later January = 1 @@ -45,7 +45,7 @@ def gmtime(secs): yday = days month = January while 1: - md = mdays[month] + (month = February and isleap(year)) + md = mdays[month] + (month == February and isleap(year)) if days < md: break days = days - md month = month + 1 @@ -122,7 +122,7 @@ def weekday(year, month, day): # Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month def monthrange(year, month): day1 = weekday(year, month, 1) - ndays = mdays[month] + (month = February and isleap(year)) + ndays = mdays[month] + (month == February and isleap(year)) return day1, ndays # Return a matrix representing a month's calendar @@ -161,7 +161,7 @@ def center(str, width): # Print a single week (no newline) def prweek(week, width): for day in week: - if day = 0: print ' '*width, + if day == 0: print ' '*width, else: if width > 2: print ' '*(width-3), if day < 10: print '', @@ -19,7 +19,7 @@ def cmp(f1, f2): # Compare two files, use the cache if possible. if s1[0] <> 8 or s2[0] <> 8: # Either is a not a plain file -- always report as different return 0 - if s1 = s2: + if s1 == s2: # type, size & mtime match -- report same return 1 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. try: cs1, cs2, outcome = cache[key] # cache hit - if s1 = cs1 and s2 = cs2: + if s1 == cs1 and s2 == cs2: # cached signatures match return outcome # stale cached signature(s) diff --git a/Lib/cmpcache.py b/Lib/cmpcache.py index e846f58..20202e2 100644 --- a/Lib/cmpcache.py +++ b/Lib/cmpcache.py @@ -29,7 +29,7 @@ def cmp(f1, f2): if not S_ISREG(s1[0]) or not S_ISREG(s2[0]): # Either is a not a plain file -- always report as different return 0 - if s1 = s2: + if s1 == s2: # type, size & mtime match -- report same return 1 if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother @@ -40,7 +40,7 @@ def cmp(f1, f2): if cache.has_key(key): cs1, cs2, outcome = cache[key] # cache hit - if s1 = cs1 and s2 = cs2: + if s1 == cs1 and s2 == cs2: # cached signatures match return outcome # stale cached signature(s) diff --git a/Lib/commands.py b/Lib/commands.py index 4d16eef..a6084a5 100644 --- a/Lib/commands.py +++ b/Lib/commands.py @@ -25,8 +25,8 @@ def getstatusoutput(cmd): pipe = posix.popen('{ ' + cmd + '; } 2>&1', 'r') text = pipe.read() sts = pipe.close() - if sts = None: sts = 0 - if text[-1:] = '\n': text = text[:-1] + if sts == None: sts = 0 + if text[-1:] == '\n': text = text[:-1] return sts, text diff --git a/Lib/dircmp.py b/Lib/dircmp.py index 0c6b4a7..f4eea1f 100644 --- a/Lib/dircmp.py +++ b/Lib/dircmp.py @@ -174,7 +174,7 @@ def cmp(a, b): # def remove(list, item): for i in range(len(list)): - if list[i] = item: + if list[i] == item: del list[i] break @@ -22,8 +22,8 @@ def disassemble(co, lasti): while i < n: c = code[i] op = ord(c) - if op = SET_LINENO and i > 0: print # Extra blank line - if i = lasti: print '-->', + if op == SET_LINENO and i > 0: print # Extra blank line + if i == lasti: print '-->', else: print ' ', if i in labels: print '>>', else: print ' ', diff --git a/Lib/dump.py b/Lib/dump.py index cecc275..ec895b7 100644 --- a/Lib/dump.py +++ b/Lib/dump.py @@ -31,7 +31,7 @@ def dumpsymtab(dict): def dumpvar(name, x): import sys t = type(x) - if t = type({}): + if t == type({}): print name, '= {}' for key in x.keys(): item = x[key] @@ -42,7 +42,7 @@ def dumpvar(name, x): if not printable(x): print '#', print name, '=', `x` - elif t = type(sys): + elif t == type(sys): print 'import', name, '#', x else: print '#', name, '=', x @@ -58,6 +58,6 @@ def printable(x): if not printable(item): return 0 return 1 - if x = {}: + if x == {}: return 1 return 0 diff --git a/Lib/fnmatch.py b/Lib/fnmatch.py index 1e7dbb3..549e0e7 100644 --- a/Lib/fnmatch.py +++ b/Lib/fnmatch.py @@ -5,64 +5,70 @@ def fnmatch(name, pat): # Check for simple case: no special characters # if not ('*' in pat or '?' in pat or '[' in pat): - return name = pat + return name == pat # # Check for common cases: *suffix and prefix* # - if pat[0] = '*': + if pat[0] == '*': p1 = pat[1:] if not ('*' in p1 or '?' in p1 or '[' in p1): start = len(name) - len(p1) - return start >= 0 and name[start:] = p1 - elif pat[-1:] = '*': + return start >= 0 and name[start:] == p1 + elif pat[-1:] == '*': p1 = pat[:-1] if not ('*' in p1 or '?' in p1 or '[' in p1): - return name[:len(p1)] = p1 + return name[:len(p1)] == p1 # # General case # return fnmatch1(name, pat) def fnmatch1(name, pat): - for i in range(len(pat)): + i, n = 0, len(pat) + while i < n: c = pat[i] - if c = '*': + if c == '*': p1 = pat[i+1:] if not ('*' in p1 or '?' in p1 or '[' in p1): start = len(name) - len(p1) - return start >= 0 and name[start:] = p1 + return start >= 0 and name[start:] == p1 for i in range(i, len(name) + 1): if fnmatch1(name[i:], p1): return 1 return 0 - elif c = '?': + elif c == '?': if len(name) <= i : return 0 - elif c = '[': + elif c == '[': c, rest = name[i], name[i+1:] i, n = i+1, len(pat) - 1 match = 0 exclude = 0 - if i < n and pat[i] = '!': + if i < n and pat[i] == '!': exclude = 1 i = i+1 while i < n: - if pat[i] = c: match = 1 + if pat[i] == c: match = 1 i = i+1 - if i >= n or pat[i] = ']': + if i >= n or pat[i] == ']': break - if pat[i] = '-': + if pat[i] == '-': i = i+1 - if i >= n or pat[i] = ']': + if i >= n or pat[i] == ']': break - match = (pat[i-2] <= c <= pat[i]) + if pat[i-2] <= c <= pat[i]: + match = 1 i = i+1 - if match = exclude: + if i >= n or pat[i] == ']': + break + if match == exclude: return 0 return fnmatch1(rest, pat[i+1:]) else: if name[i:i+1] <> c: return 0 - return 1 + i = i+1 + # We don't get here if the pattern contained * or [...] + return i >= len(name) def fnmatchlist(names, pat): res = [] diff --git a/Lib/getopt.py b/Lib/getopt.py index ef72fbc..0b71d0f 100644 --- a/Lib/getopt.py +++ b/Lib/getopt.py @@ -22,15 +22,15 @@ error = 'getopt error' def getopt(args, options): list = [] - while args and args[0][0] = '-' and args[0] <> '-': - if args[0] = '--': + while args and args[0][0] == '-' and args[0] <> '-': + if args[0] == '--': args = args[1:] break optstring, args = args[0][1:], args[1:] while optstring <> '': opt, optstring = optstring[0], optstring[1:] if classify(opt, options): # May raise exception as well - if optstring = '': + if optstring == '': if not args: raise error, 'option -' + opt + ' requires argument' optstring, args = args[0], args[1:] @@ -42,6 +42,6 @@ def getopt(args, options): def classify(opt, options): # Helper to check type of option for i in range(len(options)): - if opt = options[i] <> ':': - return options[i+1:i+2] = ':' + if opt == options[i] <> ':': + return options[i+1:i+2] == ':' raise error, 'option -' + opt + ' not recognized' diff --git a/Lib/glob.py b/Lib/glob.py index e29095c..4c7e084 100644 --- a/Lib/glob.py +++ b/Lib/glob.py @@ -7,7 +7,7 @@ import fnmatch def glob(pathname): if not has_magic(pathname): return [pathname] dirname, basename = path.split(pathname) - if dirname[-1:] = '/' and dirname <> '/': + if dirname[-1:] == '/' and dirname <> '/': dirname = dirname[:-1] if has_magic(dirname): list = glob(dirname) @@ -34,9 +34,10 @@ def glob1(dirname, pattern): names = posix.listdir(dirname) except posix.error: return [] + names.sort() result = [] for name in names: - if name[0] <> '.' or pattern[0] = '.': + if name[0] <> '.' or pattern[0] == '.': if fnmatch.fnmatch(name, pattern): result.append(name) return result diff --git a/Lib/grep.py b/Lib/grep.py index bfee3f5..21ef8d8 100644 --- a/Lib/grep.py +++ b/Lib/grep.py @@ -30,7 +30,7 @@ def ggrep(syntax, pat, filename): prefix = string.rjust(`lineno`, 3) + ': ' print prefix + line if 0: # XXX - start, end = prog.regs()[0] + start, end = prog.regs[0] line = line[:start] if '\t' not in line: prefix = ' ' * (len(prefix) + start) diff --git a/Lib/irix5/auds.py b/Lib/irix5/auds.py index 549c0a7..fb992a9 100755 --- a/Lib/irix5/auds.py +++ b/Lib/irix5/auds.py @@ -69,7 +69,7 @@ def stretch(s, a, b): ib = ib+b if i >= m: break - if ib = ja: + if ib == ja: out.append(y[i]) else: out.append((y[i]*(ja-(ib-b)) + y[i-1]*(ib-ja)) / b) diff --git a/Lib/irix5/flp.py b/Lib/irix5/flp.py index 71a8f66..dfbad01 100755 --- a/Lib/irix5/flp.py +++ b/Lib/irix5/flp.py @@ -49,7 +49,7 @@ def parse_forms(filename): def _open_formfile(filename): if filename[-3:] <> '.fd': filename = filename + '.fd' - if filename[0] = '/': + if filename[0] == '/': try: fp = open(filename,'r') except IOError: @@ -62,7 +62,7 @@ def _open_formfile(filename): break except IOError: fp = None - if fp = None: + if fp == None: raise error, 'Cannot find forms file ' + filename return fp @@ -77,7 +77,7 @@ def _parse_fd_header(file): # Now skip until we know number of forms while 1: datum = _parse_1_line(file) - if type(datum) = type(()) and datum[0] = 'Numberofforms': + if type(datum) == type(()) and datum[0] == 'Numberofforms': break return datum[1] # @@ -89,7 +89,7 @@ def _parse_fd_form(file, name): if datum <> FORMLINE: raise error, 'Missing === FORM === line' form = _parse_object(file) - if form.Name = name or name = None: + if form.Name == name or name == None: objs = [] for j in range(form.Numberofobjects): obj = _parse_object(file) @@ -147,7 +147,7 @@ def _parse_line(line): if not a: return line name = line[:a[1][1]] - if name[0] = 'N': + if name[0] == 'N': name = string.joinfields(string.split(name),'') name = string.lower(name) name = string.upper(name[0]) + name[1:] @@ -167,7 +167,7 @@ def _readline(file): def _parse_1_line(file): line = _readline(file) - while line = '': + while line == '': line = _readline(file) return _parse_line(line) @@ -176,7 +176,7 @@ def _skip_object(file): while not line in (SPLITLINE, FORMLINE, ENDLINE): pos = file.tell() line = _readline(file) - if line = FORMLINE: + if line == FORMLINE: file.seek(pos) def _parse_object(file): @@ -185,7 +185,7 @@ def _parse_object(file): pos = file.tell() datum = _parse_1_line(file) if datum in (SPLITLINE, FORMLINE, ENDLINE): - if datum = FORMLINE: + if datum == FORMLINE: file.seek(pos) return obj if type(datum) <> type(()): @@ -266,27 +266,27 @@ def _create_object(form, odata): # Internal crfunc: helper function that returns correct create function # def _select_crfunc(fm, cl): - if cl = FL.BEGIN_GROUP: return fm.bgn_group - elif cl = FL.END_GROUP: return fm.end_group - elif cl = FL.BITMAP: return fm.add_bitmap - elif cl = FL.BOX: return fm.add_box - elif cl = FL.BROWSER: return fm.add_browser - elif cl = FL.BUTTON: return fm.add_button - elif cl = FL.CHART: return fm.add_chart - elif cl = FL.CHOICE: return fm.add_choice - elif cl = FL.CLOCK: return fm.add_clock - elif cl = FL.COUNTER: return fm.add_counter - elif cl = FL.DIAL: return fm.add_dial - elif cl = FL.FREE: return fm.add_free - elif cl = FL.INPUT: return fm.add_input - elif cl = FL.LIGHTBUTTON: return fm.add_lightbutton - elif cl = FL.MENU: return fm.add_menu - elif cl = FL.POSITIONER: return fm.add_positioner - elif cl = FL.ROUNDBUTTON: return fm.add_roundbutton - elif cl = FL.SLIDER: return fm.add_slider - elif cl = FL.VALSLIDER: return fm.add_valslider - elif cl = FL.TEXT: return fm.add_text - elif cl = FL.TIMER: return fm.add_timer + if cl == FL.BEGIN_GROUP: return fm.bgn_group + elif cl == FL.END_GROUP: return fm.end_group + elif cl == FL.BITMAP: return fm.add_bitmap + elif cl == FL.BOX: return fm.add_box + elif cl == FL.BROWSER: return fm.add_browser + elif cl == FL.BUTTON: return fm.add_button + elif cl == FL.CHART: return fm.add_chart + elif cl == FL.CHOICE: return fm.add_choice + elif cl == FL.CLOCK: return fm.add_clock + elif cl == FL.COUNTER: return fm.add_counter + elif cl == FL.DIAL: return fm.add_dial + elif cl == FL.FREE: return fm.add_free + elif cl == FL.INPUT: return fm.add_input + elif cl == FL.LIGHTBUTTON: return fm.add_lightbutton + elif cl == FL.MENU: return fm.add_menu + elif cl == FL.POSITIONER: return fm.add_positioner + elif cl == FL.ROUNDBUTTON: return fm.add_roundbutton + elif cl == FL.SLIDER: return fm.add_slider + elif cl == FL.VALSLIDER: return fm.add_valslider + elif cl == FL.TEXT: return fm.add_text + elif cl == FL.TIMER: return fm.add_timer else: raise error, 'Unknown object type: ' + `cl` diff --git a/Lib/irix5/panel.py b/Lib/irix5/panel.py index 9fda1c6..21a17ba 100755 --- a/Lib/irix5/panel.py +++ b/Lib/irix5/panel.py @@ -17,7 +17,7 @@ debug = 0 # Test if an object is a list. # def is_list(x): - return type(x) = type([]) + return type(x) == type([]) # Reverse a list. @@ -34,7 +34,7 @@ def reverse(list): # def getattrlist(list, name): for item in list: - if item and is_list(item) and item[0] = name: + if item and is_list(item) and item[0] == name: return item[1:] return [] @@ -43,8 +43,8 @@ def getattrlist(list, name): # def getproplist(list, name): for item in list: - if item and is_list(item) and item[0] = 'prop': - if len(item) > 1 and item[1] = name: + if item and is_list(item) and item[0] == 'prop': + if len(item) > 1 and item[1] == name: return item[2:] return [] @@ -53,7 +53,7 @@ def getproplist(list, name): # def is_endgroup(list): x = getproplist(list, 'end-of-group') - return (x and x[0] = '#t') + return (x and x[0] == '#t') # Neatly display an actuator definition given as S-expression @@ -63,13 +63,13 @@ def show_actuator(prefix, a): for item in a: if not is_list(item): print prefix, item - elif item and item[0] = 'al': + elif item and item[0] == 'al': print prefix, 'Subactuator list:' for a in item[1:]: show_actuator(prefix + ' ', a) - elif len(item) = 2: + elif len(item) == 2: print prefix, item[0], '=>', item[1] - elif len(item) = 3 and item[0] = 'prop': + elif len(item) == 3 and item[0] == 'prop': print prefix, 'Prop', item[1], '=>', print item[2] else: @@ -82,13 +82,13 @@ def show_panel(prefix, p): for item in p: if not is_list(item): print prefix, item - elif item and item[0] = 'al': + elif item and item[0] == 'al': print prefix, 'Actuator list:' for a in item[1:]: show_actuator(prefix + ' ', a) - elif len(item) = 2: + elif len(item) == 2: print prefix, item[0], '=>', item[1] - elif len(item) = 3 and item[0] = 'prop': + elif len(item) == 3 and item[0] == 'prop': print prefix, 'Prop', item[1], '=>', print item[2] else: @@ -112,14 +112,14 @@ def dummy_callback(arg): # def assign_members(target, attrlist, exclist, prefix): for item in attrlist: - if is_list(item) and len(item) = 2 and item[0] not in exclist: + if is_list(item) and len(item) == 2 and item[0] not in exclist: name, value = item[0], item[1] ok = 1 if value[0] in '-0123456789': value = eval(value) - elif value[0] = '"': + elif value[0] == '"': value = value[1:-1] - elif value = 'move-then-resize': + elif value == 'move-then-resize': # Strange default set by Panel Editor... ok = 0 else: @@ -148,7 +148,7 @@ def build_actuator(descr): else: actuatorname = '' type = descr[0] - if type[:4] = 'pnl_': type = type[4:] + if type[:4] == 'pnl_': type = type[4:] act = pnl.mkact(type) act.downfunc = act.activefunc = act.upfunc = dummy_callback # @@ -158,9 +158,9 @@ def build_actuator(descr): # datalist = getattrlist(descr, 'data') prefix = '' - if type[-4:] = 'puck': + if type[-4:] == 'puck': prefix = 'puck_' - elif type = 'mouse': + elif type == 'mouse': prefix = 'mouse_' assign_members(act, datalist, [], prefix) # diff --git a/Lib/irix5/panelparser.py b/Lib/irix5/panelparser.py index 9c9ee02..1b069fa 100755 --- a/Lib/irix5/panelparser.py +++ b/Lib/irix5/panelparser.py @@ -20,16 +20,16 @@ def tokenize_string(s): c = s[:1] if c in whitespace: s = s[1:] - elif c = ';': + elif c == ';': s = '' - elif c = '"': + elif c == '"': n = len(s) i = 1 while i < n: c = s[i] i = i+1 - if c = '"': break - if c = '\\': i = i+1 + if c == '"': break + if c == '\\': i = i+1 tokens.append(s[:i]) s = s[i:] elif c in operators: @@ -78,9 +78,9 @@ def parse_expr(tokens): while 1: if not tokens: raise syntax_error, 'missing ")"' - if tokens[0] = ')': + if tokens[0] == ')': return expr, tokens[1:] - elif tokens[0] = '(': + elif tokens[0] == '(': subexpr, tokens = parse_expr(tokens) expr.append(subexpr) else: diff --git a/Lib/lib-old/dump.py b/Lib/lib-old/dump.py index cecc275..ec895b7 100644 --- a/Lib/lib-old/dump.py +++ b/Lib/lib-old/dump.py @@ -31,7 +31,7 @@ def dumpsymtab(dict): def dumpvar(name, x): import sys t = type(x) - if t = type({}): + if t == type({}): print name, '= {}' for key in x.keys(): item = x[key] @@ -42,7 +42,7 @@ def dumpvar(name, x): if not printable(x): print '#', print name, '=', `x` - elif t = type(sys): + elif t == type(sys): print 'import', name, '#', x else: print '#', name, '=', x @@ -58,6 +58,6 @@ def printable(x): if not printable(item): return 0 return 1 - if x = {}: + if x == {}: return 1 return 0 diff --git a/Lib/lib-old/grep.py b/Lib/lib-old/grep.py index bfee3f5..21ef8d8 100644 --- a/Lib/lib-old/grep.py +++ b/Lib/lib-old/grep.py @@ -30,7 +30,7 @@ def ggrep(syntax, pat, filename): prefix = string.rjust(`lineno`, 3) + ': ' print prefix + line if 0: # XXX - start, end = prog.regs()[0] + start, end = prog.regs[0] line = line[:start] if '\t' not in line: prefix = ' ' * (len(prefix) + start) diff --git a/Lib/lib-old/newdir.py b/Lib/lib-old/newdir.py index 9d07d6c..4994bf9 100644 --- a/Lib/lib-old/newdir.py +++ b/Lib/lib-old/newdir.py @@ -53,7 +53,7 @@ def listattrs(x): return total i = 0 while i+1 < len(total): - if total[i] = total[i+1]: + if total[i] == total[i+1]: del total[i+1] else: i = i+1 @@ -62,7 +62,7 @@ def listattrs(x): # Helper to recognize functions # def is_function(x): - return type(x) = type(is_function) + return type(x) == type(is_function) # Approximation of builtin dir(); this lists the user's # variables by default, not the current local name space. @@ -71,7 +71,7 @@ def is_function(x): # class _dirclass: def dir(args): - if type(args) = type(()): + if type(args) == type(()): return listattrs(args[1]) else: import __main__ diff --git a/Lib/lib-old/tb.py b/Lib/lib-old/tb.py index ec63104..ef0c4b5 100644 --- a/Lib/lib-old/tb.py +++ b/Lib/lib-old/tb.py @@ -40,19 +40,19 @@ def browser(tb): break cmd = string.strip(line) if cmd: - if cmd = 'quit': + if cmd == 'quit': break - elif cmd = 'list': + elif cmd == 'list': browserlist(tb) - elif cmd = 'up': + elif cmd == 'up': if ptr-1 >= 0: ptr = ptr-1 else: print 'Bottom of stack.' - elif cmd = 'down': + elif cmd == 'down': if ptr+1 < len(tblist): ptr = ptr+1 else: print 'Top of stack.' - elif cmd = 'locals': + elif cmd == 'locals': printsymbols(tb.tb_frame.f_locals) - elif cmd = 'globals': + elif cmd == 'globals': printsymbols(tb.tb_frame.f_globals) elif cmd in ('?', 'help'): browserhelp() @@ -65,10 +65,10 @@ def browserlist(tb): last = lineno first = max(1, last-10) for i in range(first, last+1): - if i = lineno: prefix = '***' + string.rjust(`i`, 4) + ':' + if i == lineno: prefix = '***' + string.rjust(`i`, 4) + ':' else: prefix = string.rjust(`i`, 7) + ':' line = readfileline(filename, i) - if line[-1:] = '\n': line = line[:-1] + if line[-1:] == '\n': line = line[:-1] print prefix + line def browserexec(tb, cmd): @@ -126,24 +126,24 @@ def printsymbols(d): print def printobject(v, maxlevel): - if v = None: + if v == None: print 'None', elif type(v) in (type(0), type(0.0)): print v, - elif type(v) = type(''): + elif type(v) == type(''): if len(v) > 20: print `v[:17] + '...'`, else: print `v`, - elif type(v) = type(()): + elif type(v) == type(()): print '(', printlist(v, maxlevel) print ')', - elif type(v) = type([]): + elif type(v) == type([]): print '[', printlist(v, maxlevel) print ']', - elif type(v) = type({}): + elif type(v) == type({}): print '{', printdict(v, maxlevel) print '}', @@ -152,7 +152,7 @@ def printobject(v, maxlevel): def printlist(v, maxlevel): n = len(v) - if n = 0: return + if n == 0: return if maxlevel <= 0: print '...', return @@ -164,7 +164,7 @@ def printlist(v, maxlevel): def printdict(v, maxlevel): keys = v.keys() n = len(keys) - if n = 0: return + if n == 0: return if maxlevel <= 0: print '...', return @@ -187,8 +187,8 @@ def readfileline(filename, lineno): cache_ok = 0 if _filecache.has_key(filename): cached_stat, lines = _filecache[filename] - if stat[ST_SIZE] = cached_stat[ST_SIZE] and \ - stat[ST_MTIME] = cached_stat[ST_MTIME]: + if stat[ST_SIZE] == cached_stat[ST_SIZE] and \ + stat[ST_MTIME] == cached_stat[ST_MTIME]: cache_ok = 1 else: print 'Stale cache entry for', filename diff --git a/Lib/lib-stdwin/Buttons.py b/Lib/lib-stdwin/Buttons.py index 949e128..d1435d3 100644 --- a/Lib/lib-stdwin/Buttons.py +++ b/Lib/lib-stdwin/Buttons.py @@ -110,7 +110,7 @@ class LabelAppearance: # def draw(self, (d, area)): area = _rect.intersect(area, self.bounds) - if area = _rect.empty: + if area == _rect.empty: return d.cliprect(area) self.drawit(d) diff --git a/Lib/lib-stdwin/CSplit.py b/Lib/lib-stdwin/CSplit.py index 5c57d90..90d137e 100644 --- a/Lib/lib-stdwin/CSplit.py +++ b/Lib/lib-stdwin/CSplit.py @@ -43,7 +43,7 @@ class CSplit(Split): # XXX One day Python will have automatic conversions... n = len(self.children) fn = float(n) - if n = 0: return + if n == 0: return (left, top), (right, bottom) = bounds width, height = right-left, bottom-top child_width, child_height = width*3/(n+4), height*3/(n+4) diff --git a/Lib/lib-stdwin/DirList.py b/Lib/lib-stdwin/DirList.py index 20a0fe8..0066c58 100644 --- a/Lib/lib-stdwin/DirList.py +++ b/Lib/lib-stdwin/DirList.py @@ -25,7 +25,7 @@ class DirList(VSplit): if path.isdir(path.join(dirname, name)): fullname = path.join(dirname, name) btn = SubdirButton().definetext(self, fullname) - elif name[-3:] = '.py': + elif name[-3:] == '.py': btn = ModuleButton().definetext(self, name) else: btn = FileButton().definetext(self, name) diff --git a/Lib/lib-stdwin/Split.py b/Lib/lib-stdwin/Split.py index b169d72..aacfa98 100644 --- a/Lib/lib-stdwin/Split.py +++ b/Lib/lib-stdwin/Split.py @@ -116,7 +116,7 @@ class Split: if not self.keybd_focus: self.set_keybd_focus(self.keybd_interest[0]) type, detail = type_detail - if type = WE_COMMAND and detail = WC_TAB and \ + if type == WE_COMMAND and detail == WC_TAB and \ len(self.keybd_interest) > 1: self.next_keybd_focus() return @@ -144,9 +144,9 @@ class Split: self.timer_interest.remove(child) if child in self.altdraw_interest: self.altdraw_interest.remove(child) - if child = self.mouse_focus: + if child == self.mouse_focus: self.mouse_focus = None - if child = self.keybd_focus: + if child == self.keybd_focus: self.keybd_focus = None # def need_mouse(self, child): @@ -154,7 +154,7 @@ class Split: self.mouse_interest.append(child) self.parent.need_mouse(self) def no_mouse(self, child): - if child = self.mouse_focus: + if child == self.mouse_focus: self.mouse_focus = None if child in self.mouse_interest: self.mouse_interest.remove(child) @@ -168,7 +168,7 @@ class Split: if not self.keybd_focus: self.set_keybd_focus(child) def no_keybd(self, child): - if child = self.keybd_focus: + if child == self.keybd_focus: self.keybd_focus = None # Don't call child.deactivate() if child in self.keybd_interest: self.keybd_interest.remove(child) diff --git a/Lib/lib-stdwin/StripChart.py b/Lib/lib-stdwin/StripChart.py index d58f835..5bce412 100644 --- a/Lib/lib-stdwin/StripChart.py +++ b/Lib/lib-stdwin/StripChart.py @@ -51,7 +51,7 @@ class StripChart(LabelAppearance, NoReactivity): # def draw(self, (d, area)): area = rect.intersect(area, self.bounds) - if area = rect.empty: + if area == rect.empty: return d.cliprect(area) d.erase(self.bounds) diff --git a/Lib/lib-stdwin/WindowParent.py b/Lib/lib-stdwin/WindowParent.py index a0593c5..697ed07 100644 --- a/Lib/lib-stdwin/WindowParent.py +++ b/Lib/lib-stdwin/WindowParent.py @@ -149,26 +149,26 @@ class WindowParent(ManageOneChild): # Only call dispatch once we are realized # def dispatch(self, (type, win, detail)): - if type = WE_DRAW: + if type == WE_DRAW: d = self.win.begindrawing() self.child.draw(d, detail) del d if self.do_altdraw: self.child.altdraw(detail) - elif type = WE_MOUSE_DOWN: + elif type == WE_MOUSE_DOWN: if self.do_mouse: self.child.mouse_down(detail) - elif type = WE_MOUSE_MOVE: + elif type == WE_MOUSE_MOVE: if self.do_mouse: self.child.mouse_move(detail) - elif type = WE_MOUSE_UP: + elif type == WE_MOUSE_UP: if self.do_mouse: self.child.mouse_up(detail) elif type in (WE_CHAR, WE_COMMAND): if self.do_keybd: self.child.keybd(type, detail) - elif type = WE_TIMER: + elif type == WE_TIMER: if self.do_timer: self.child.timer() - elif type = WE_SIZE: + elif type == WE_SIZE: self.fixup() - elif type = WE_CLOSE: + elif type == WE_CLOSE: self.close_trigger() - elif type = WE_MENU: + elif type == WE_MENU: self.menu_trigger(detail) if self.pending_destroy: self.destroy() diff --git a/Lib/lib-stdwin/WindowSched.py b/Lib/lib-stdwin/WindowSched.py index 9125317..67c3afb 100644 --- a/Lib/lib-stdwin/WindowSched.py +++ b/Lib/lib-stdwin/WindowSched.py @@ -21,7 +21,7 @@ def delayfunc(msecs): # # Use millisleep for very short delays or if there are no windows # - if msecs < 100 or mainloop.countwindows() = 0: + if msecs < 100 or mainloop.countwindows() == 0: if msecs > 0: time.millisleep(msecs) return @@ -46,7 +46,7 @@ cancel = q.cancel # Emptiness check must check both queues # def empty(): - return q.empty() and mainloop.countwindows() = 0 + return q.empty() and mainloop.countwindows() == 0 # Run until there is nothing left to do # diff --git a/Lib/lib-stdwin/dirwin.py b/Lib/lib-stdwin/dirwin.py index d0a8525..beb5222 100644 --- a/Lib/lib-stdwin/dirwin.py +++ b/Lib/lib-stdwin/dirwin.py @@ -10,7 +10,7 @@ import dircache def action(w, string, i, detail): (h, v), clicks, button, mask = detail - if clicks = 2: + if clicks == 2: name = path.join(w.name, string) try: w2 = anywin.open(name) diff --git a/Lib/lib-stdwin/formatter.py b/Lib/lib-stdwin/formatter.py index aea7deb..b2d4add 100644 --- a/Lib/lib-stdwin/formatter.py +++ b/Lib/lib-stdwin/formatter.py @@ -175,20 +175,20 @@ def test(): winsize = w.getwinsize() while 1: type, window, detail = stdwinq.getevent() - if type = WE_CLOSE: + if type == WE_CLOSE: break - elif type = WE_SIZE: + elif type == WE_SIZE: newsize = w.getwinsize() if newsize <> winsize: w.change((0,0), winsize) winsize = newsize w.change((0,0), winsize) - elif type = WE_MOUSE_DOWN: + elif type == WE_MOUSE_DOWN: stage = (stage + 1) % len(stages) justify, center, title = stages[stage] w.settitle(title) w.change((0, 0), (1000, 1000)) - elif type = WE_DRAW: + elif type == WE_DRAW: width, height = winsize f = formatter().init(w.begindrawing(), 0, 0, width) f.center = center @@ -198,7 +198,7 @@ def test(): for font in font1, font2, font1: f.setfont(font) for word in words: - space = 1 + (word[-1:] = '.') + space = 1 + (word[-1:] == '.') f.addword(word, space) if center and space > 1: f.flush() diff --git a/Lib/lib-stdwin/gwin.py b/Lib/lib-stdwin/gwin.py index c2ec11f..12ed90b 100644 --- a/Lib/lib-stdwin/gwin.py +++ b/Lib/lib-stdwin/gwin.py @@ -49,44 +49,44 @@ def mainloop(): # Handle events until no windows left def treatevent(e): # Handle a stdwin event type, w, detail = e - if type = WE_DRAW: + if type == WE_DRAW: w.draw(w, detail) - elif type = WE_MENU: + elif type == WE_MENU: m, item = detail m.action[item](w, m, item) - elif type = WE_COMMAND: + elif type == WE_COMMAND: treatcommand(w, detail) - elif type = WE_CHAR: + elif type == WE_CHAR: w.char(w, detail) - elif type = WE_MOUSE_DOWN: + elif type == WE_MOUSE_DOWN: if detail[1] > 1: w.m2down(w, detail) else: w.mdown(w, detail) - elif type = WE_MOUSE_MOVE: + elif type == WE_MOUSE_MOVE: w.mmove(w, detail) - elif type = WE_MOUSE_UP: + elif type == WE_MOUSE_UP: if detail[1] > 1: w.m2up(w, detail) else: w.mup(w, detail) - elif type = WE_SIZE: + elif type == WE_SIZE: w.size(w, w.getwinsize()) - elif type = WE_ACTIVATE: + elif type == WE_ACTIVATE: w.activate(w) - elif type = WE_DEACTIVATE: + elif type == WE_DEACTIVATE: w.deactivate(w) - elif type = WE_MOVE: + elif type == WE_MOVE: w.move(w) - elif type = WE_TIMER: + elif type == WE_TIMER: w.timer(w) - elif type = WE_CLOSE: + elif type == WE_CLOSE: w.close(w) def treatcommand(w, type): # Handle a we_command event - if type = WC_CLOSE: + if type == WC_CLOSE: w.close(w) - elif type = WC_RETURN: + elif type == WC_RETURN: w.enter(w) - elif type = WC_TAB: + elif type == WC_TAB: w.tab(w) - elif type = WC_BACKSPACE: + elif type == WC_BACKSPACE: w.backspace(w) elif type in (WC_LEFT, WC_UP, WC_RIGHT, WC_DOWN): w.arrow(w, type) @@ -101,13 +101,13 @@ def close(w): # Close method break def arrow(w, detail): # Arrow key method - if detail = WC_LEFT: + if detail == WC_LEFT: w.kleft(w) - elif detail = WC_UP: + elif detail == WC_UP: w.kup(w) - elif detail = WC_RIGHT: + elif detail == WC_RIGHT: w.kright(w) - elif detail = WC_DOWN: + elif detail == WC_DOWN: w.kdown(w) diff --git a/Lib/lib-stdwin/tablewin.py b/Lib/lib-stdwin/tablewin.py index f9ab907..eba161d 100644 --- a/Lib/lib-stdwin/tablewin.py +++ b/Lib/lib-stdwin/tablewin.py @@ -164,13 +164,13 @@ def whichcol(w, h): # Return column number (may be >= len(w.data)) return len(w.data) def arrow(w, type): - if type = WC_LEFT: + if type == WC_LEFT: incr = -1, 0 - elif type = WC_UP: + elif type == WC_UP: incr = 0, -1 - elif type = WC_RIGHT: + elif type == WC_RIGHT: incr = 1, 0 - elif type = WC_DOWN: + elif type == WC_DOWN: incr = 0, 1 else: return diff --git a/Lib/macpath.py b/Lib/macpath.py index 58cbb88..533b052 100644 --- a/Lib/macpath.py +++ b/Lib/macpath.py @@ -21,7 +21,7 @@ def isabs(s): def join(s, t): if (not s) or isabs(t): return t - if t[:1] = ':': t = t[1:] + if t[:1] == ':': t = t[1:] if ':' not in s: s = ':' + s if s[-1:] <> ':': @@ -40,7 +40,7 @@ def split(s): if ':' not in s: return '', s colon = 0 for i in range(len(s)): - if s[i] = ':': colon = i+1 + if s[i] == ':': colon = i+1 return s[:colon], s[colon:] diff --git a/Lib/newdir.py b/Lib/newdir.py index 9d07d6c..4994bf9 100644 --- a/Lib/newdir.py +++ b/Lib/newdir.py @@ -53,7 +53,7 @@ def listattrs(x): return total i = 0 while i+1 < len(total): - if total[i] = total[i+1]: + if total[i] == total[i+1]: del total[i+1] else: i = i+1 @@ -62,7 +62,7 @@ def listattrs(x): # Helper to recognize functions # def is_function(x): - return type(x) = type(is_function) + return type(x) == type(is_function) # Approximation of builtin dir(); this lists the user's # variables by default, not the current local name space. @@ -71,7 +71,7 @@ def is_function(x): # class _dirclass: def dir(args): - if type(args) = type(()): + if type(args) == type(()): return listattrs(args[1]) else: import __main__ diff --git a/Lib/persist.py b/Lib/persist.py index 065a3ea..52cc6fb 100755 --- a/Lib/persist.py +++ b/Lib/persist.py @@ -160,23 +160,23 @@ def dumptype(x, typedict, types, stack): typedict[xrepr] = uid if typeswitch.has_key(xrepr): print FN, '[', `uid`, '] =', typeswitch[xrepr] - elif x = type(sys): + elif x == type(sys): print 'import sys' print FN, '[', `uid`, '] = type(sys)' - elif x = type(sys.stderr): + elif x == type(sys.stderr): print 'import sys' print FN, '[', `uid`, '] = type(sys.stderr)' - elif x = type(dumptype): + elif x == type(dumptype): print 'def some_function(): pass' print FN, '[', `uid`, '] = type(some_function)' - elif x = type(some_class): + elif x == type(some_class): print 'class some_class(): pass' print FN, '[', `uid`, '] = type(some_class)' - elif x = type(some_instance): + elif x == type(some_instance): print 'class another_class(): pass' print 'some_instance = another_class()' print FN, '[', `uid`, '] = type(some_instance)' - elif x = type(some_instance.method): + elif x == type(some_instance.method): print 'class yet_another_class():' print ' def method(): pass' print 'another_instance = yet_another_class()' diff --git a/Lib/plat-irix5/flp.py b/Lib/plat-irix5/flp.py index 71a8f66..dfbad01 100755 --- a/Lib/plat-irix5/flp.py +++ b/Lib/plat-irix5/flp.py @@ -49,7 +49,7 @@ def parse_forms(filename): def _open_formfile(filename): if filename[-3:] <> '.fd': filename = filename + '.fd' - if filename[0] = '/': + if filename[0] == '/': try: fp = open(filename,'r') except IOError: @@ -62,7 +62,7 @@ def _open_formfile(filename): break except IOError: fp = None - if fp = None: + if fp == None: raise error, 'Cannot find forms file ' + filename return fp @@ -77,7 +77,7 @@ def _parse_fd_header(file): # Now skip until we know number of forms while 1: datum = _parse_1_line(file) - if type(datum) = type(()) and datum[0] = 'Numberofforms': + if type(datum) == type(()) and datum[0] == 'Numberofforms': break return datum[1] # @@ -89,7 +89,7 @@ def _parse_fd_form(file, name): if datum <> FORMLINE: raise error, 'Missing === FORM === line' form = _parse_object(file) - if form.Name = name or name = None: + if form.Name == name or name == None: objs = [] for j in range(form.Numberofobjects): obj = _parse_object(file) @@ -147,7 +147,7 @@ def _parse_line(line): if not a: return line name = line[:a[1][1]] - if name[0] = 'N': + if name[0] == 'N': name = string.joinfields(string.split(name),'') name = string.lower(name) name = string.upper(name[0]) + name[1:] @@ -167,7 +167,7 @@ def _readline(file): def _parse_1_line(file): line = _readline(file) - while line = '': + while line == '': line = _readline(file) return _parse_line(line) @@ -176,7 +176,7 @@ def _skip_object(file): while not line in (SPLITLINE, FORMLINE, ENDLINE): pos = file.tell() line = _readline(file) - if line = FORMLINE: + if line == FORMLINE: file.seek(pos) def _parse_object(file): @@ -185,7 +185,7 @@ def _parse_object(file): pos = file.tell() datum = _parse_1_line(file) if datum in (SPLITLINE, FORMLINE, ENDLINE): - if datum = FORMLINE: + if datum == FORMLINE: file.seek(pos) return obj if type(datum) <> type(()): @@ -266,27 +266,27 @@ def _create_object(form, odata): # Internal crfunc: helper function that returns correct create function # def _select_crfunc(fm, cl): - if cl = FL.BEGIN_GROUP: return fm.bgn_group - elif cl = FL.END_GROUP: return fm.end_group - elif cl = FL.BITMAP: return fm.add_bitmap - elif cl = FL.BOX: return fm.add_box - elif cl = FL.BROWSER: return fm.add_browser - elif cl = FL.BUTTON: return fm.add_button - elif cl = FL.CHART: return fm.add_chart - elif cl = FL.CHOICE: return fm.add_choice - elif cl = FL.CLOCK: return fm.add_clock - elif cl = FL.COUNTER: return fm.add_counter - elif cl = FL.DIAL: return fm.add_dial - elif cl = FL.FREE: return fm.add_free - elif cl = FL.INPUT: return fm.add_input - elif cl = FL.LIGHTBUTTON: return fm.add_lightbutton - elif cl = FL.MENU: return fm.add_menu - elif cl = FL.POSITIONER: return fm.add_positioner - elif cl = FL.ROUNDBUTTON: return fm.add_roundbutton - elif cl = FL.SLIDER: return fm.add_slider - elif cl = FL.VALSLIDER: return fm.add_valslider - elif cl = FL.TEXT: return fm.add_text - elif cl = FL.TIMER: return fm.add_timer + if cl == FL.BEGIN_GROUP: return fm.bgn_group + elif cl == FL.END_GROUP: return fm.end_group + elif cl == FL.BITMAP: return fm.add_bitmap + elif cl == FL.BOX: return fm.add_box + elif cl == FL.BROWSER: return fm.add_browser + elif cl == FL.BUTTON: return fm.add_button + elif cl == FL.CHART: return fm.add_chart + elif cl == FL.CHOICE: return fm.add_choice + elif cl == FL.CLOCK: return fm.add_clock + elif cl == FL.COUNTER: return fm.add_counter + elif cl == FL.DIAL: return fm.add_dial + elif cl == FL.FREE: return fm.add_free + elif cl == FL.INPUT: return fm.add_input + elif cl == FL.LIGHTBUTTON: return fm.add_lightbutton + elif cl == FL.MENU: return fm.add_menu + elif cl == FL.POSITIONER: return fm.add_positioner + elif cl == FL.ROUNDBUTTON: return fm.add_roundbutton + elif cl == FL.SLIDER: return fm.add_slider + elif cl == FL.VALSLIDER: return fm.add_valslider + elif cl == FL.TEXT: return fm.add_text + elif cl == FL.TIMER: return fm.add_timer else: raise error, 'Unknown object type: ' + `cl` diff --git a/Lib/plat-irix5/panel.py b/Lib/plat-irix5/panel.py index 9fda1c6..21a17ba 100755 --- a/Lib/plat-irix5/panel.py +++ b/Lib/plat-irix5/panel.py @@ -17,7 +17,7 @@ debug = 0 # Test if an object is a list. # def is_list(x): - return type(x) = type([]) + return type(x) == type([]) # Reverse a list. @@ -34,7 +34,7 @@ def reverse(list): # def getattrlist(list, name): for item in list: - if item and is_list(item) and item[0] = name: + if item and is_list(item) and item[0] == name: return item[1:] return [] @@ -43,8 +43,8 @@ def getattrlist(list, name): # def getproplist(list, name): for item in list: - if item and is_list(item) and item[0] = 'prop': - if len(item) > 1 and item[1] = name: + if item and is_list(item) and item[0] == 'prop': + if len(item) > 1 and item[1] == name: return item[2:] return [] @@ -53,7 +53,7 @@ def getproplist(list, name): # def is_endgroup(list): x = getproplist(list, 'end-of-group') - return (x and x[0] = '#t') + return (x and x[0] == '#t') # Neatly display an actuator definition given as S-expression @@ -63,13 +63,13 @@ def show_actuator(prefix, a): for item in a: if not is_list(item): print prefix, item - elif item and item[0] = 'al': + elif item and item[0] == 'al': print prefix, 'Subactuator list:' for a in item[1:]: show_actuator(prefix + ' ', a) - elif len(item) = 2: + elif len(item) == 2: print prefix, item[0], '=>', item[1] - elif len(item) = 3 and item[0] = 'prop': + elif len(item) == 3 and item[0] == 'prop': print prefix, 'Prop', item[1], '=>', print item[2] else: @@ -82,13 +82,13 @@ def show_panel(prefix, p): for item in p: if not is_list(item): print prefix, item - elif item and item[0] = 'al': + elif item and item[0] == 'al': print prefix, 'Actuator list:' for a in item[1:]: show_actuator(prefix + ' ', a) - elif len(item) = 2: + elif len(item) == 2: print prefix, item[0], '=>', item[1] - elif len(item) = 3 and item[0] = 'prop': + elif len(item) == 3 and item[0] == 'prop': print prefix, 'Prop', item[1], '=>', print item[2] else: @@ -112,14 +112,14 @@ def dummy_callback(arg): # def assign_members(target, attrlist, exclist, prefix): for item in attrlist: - if is_list(item) and len(item) = 2 and item[0] not in exclist: + if is_list(item) and len(item) == 2 and item[0] not in exclist: name, value = item[0], item[1] ok = 1 if value[0] in '-0123456789': value = eval(value) - elif value[0] = '"': + elif value[0] == '"': value = value[1:-1] - elif value = 'move-then-resize': + elif value == 'move-then-resize': # Strange default set by Panel Editor... ok = 0 else: @@ -148,7 +148,7 @@ def build_actuator(descr): else: actuatorname = '' type = descr[0] - if type[:4] = 'pnl_': type = type[4:] + if type[:4] == 'pnl_': type = type[4:] act = pnl.mkact(type) act.downfunc = act.activefunc = act.upfunc = dummy_callback # @@ -158,9 +158,9 @@ def build_actuator(descr): # datalist = getattrlist(descr, 'data') prefix = '' - if type[-4:] = 'puck': + if type[-4:] == 'puck': prefix = 'puck_' - elif type = 'mouse': + elif type == 'mouse': prefix = 'mouse_' assign_members(act, datalist, [], prefix) # diff --git a/Lib/plat-irix5/panelparser.py b/Lib/plat-irix5/panelparser.py index 9c9ee02..1b069fa 100755 --- a/Lib/plat-irix5/panelparser.py +++ b/Lib/plat-irix5/panelparser.py @@ -20,16 +20,16 @@ def tokenize_string(s): c = s[:1] if c in whitespace: s = s[1:] - elif c = ';': + elif c == ';': s = '' - elif c = '"': + elif c == '"': n = len(s) i = 1 while i < n: c = s[i] i = i+1 - if c = '"': break - if c = '\\': i = i+1 + if c == '"': break + if c == '\\': i = i+1 tokens.append(s[:i]) s = s[i:] elif c in operators: @@ -78,9 +78,9 @@ def parse_expr(tokens): while 1: if not tokens: raise syntax_error, 'missing ")"' - if tokens[0] = ')': + if tokens[0] == ')': return expr, tokens[1:] - elif tokens[0] = '(': + elif tokens[0] == '(': subexpr, tokens = parse_expr(tokens) expr.append(subexpr) else: diff --git a/Lib/poly.py b/Lib/poly.py index abac4c8..3a21904 100644 --- a/Lib/poly.py +++ b/Lib/poly.py @@ -39,9 +39,9 @@ def times(a, b): return res def power(a, n): # Raise polynomial a to the positive integral power n - if n = 0: return [1] - if n = 1: return a - if n/2*2 = n: + if n == 0: return [1] + if n == 1: return a + if n/2*2 == n: b = power(a, n/2) return times(b, b) return times(power(a, n-1), a) diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 9a2ccb0..fa72ecb 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -10,8 +10,8 @@ import stat # (begins with '/'). # def join(a, b): - if b[:1] = '/': return b - if a = '' or a[-1:] = '/': return a + b + if b[:1] == '/': return b + if a == '' or a[-1:] == '/': return a + b # Note: join('x', '') returns 'x/'; is this what we want? return a + '/' + b @@ -27,7 +27,7 @@ def split(p): head, tail = '', '' for c in p: tail = tail + c - if c = '/': + if c == '/': head, tail = head + tail, '' return head, tail @@ -40,9 +40,9 @@ def split(p): def splitext(p): root, ext = '', '' for c in p: - if c = '/': + if c == '/': root, ext = root + ext + c, '' - elif c = '.' or ext: + elif c == '.' or ext: ext = ext + c else: root = root + c @@ -64,7 +64,7 @@ def commonprefix(m): for i in range(len(prefix)): if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] - if i = 0: return '' + if i == 0: return '' break return prefix @@ -122,8 +122,8 @@ def sameopenfile(fp1, fp2): # describing the same file? # def samestat(s1, s2): - return s1[stat.ST_INO] = s2[stat.ST_INO] and \ - s1[stat.ST_DEV] = s2[stat.STD_DEV] + return s1[stat.ST_INO] == s2[stat.ST_INO] and \ + s1[stat.ST_DEV] == s2[stat.STD_DEV] # Subroutine and global data used by ismount(). @@ -137,7 +137,7 @@ def _getmounts(): lines = string.splitfields(data, '\n') for line in lines: words = string.split(line) - if len(words) >= 3 and words[1] = 'on': + if len(words) >= 3 and words[1] == 'on': mounts.append(words[2]) return mounts diff --git a/Lib/sched.py b/Lib/sched.py index e7d2b87..4a45309 100644 --- a/Lib/sched.py +++ b/Lib/sched.py @@ -49,7 +49,7 @@ class scheduler: for i in range(len(q)): qtime, qpri, qact, qarg = q[i] if time < qtime: break - if time = qtime and priority < qpri: break + if time == qtime and priority < qpri: break else: i = len(q) q.insert(i, event) @@ -72,7 +72,7 @@ class scheduler: # Check whether the queue is empty. # def empty(self): - return len(self.queue) = 0 + return len(self.queue) == 0 # # Run: execute events until the queue is empty. # diff --git a/Lib/stat.py b/Lib/stat.py index fee4965..3682b20 100644 --- a/Lib/stat.py +++ b/Lib/stat.py @@ -36,22 +36,22 @@ S_IFLNK = 0120000 S_IFSOCK = 0140000 def S_ISDIR(mode): - return S_IFMT(mode) = S_IFDIR + return S_IFMT(mode) == S_IFDIR def S_ISCHR(mode): - return S_IFMT(mode) = S_IFCHR + return S_IFMT(mode) == S_IFCHR def S_ISBLK(mode): - return S_IFMT(mode) = S_IFBLK + return S_IFMT(mode) == S_IFBLK def S_ISREG(mode): - return S_IFMT(mode) = S_IFREG + return S_IFMT(mode) == S_IFREG def S_ISFIFO(mode): - return S_IFMT(mode) = S_IFIFO + return S_IFMT(mode) == S_IFIFO def S_ISLNK(mode): - return S_IFMT(mode) = S_IFLNK + return S_IFMT(mode) == S_IFLNK def S_ISSOCK(mode): - return S_IFMT(mode) = S_IFSOCK + return S_IFMT(mode) == S_IFSOCK diff --git a/Lib/statcache.py b/Lib/statcache.py index 36ecc96..bf13eb5 100644 --- a/Lib/statcache.py +++ b/Lib/statcache.py @@ -44,7 +44,7 @@ def forget(path): def forget_prefix(prefix): n = len(prefix) for path in cache.keys(): - if path[:n] = prefix: + if path[:n] == prefix: del cache[path] @@ -52,16 +52,16 @@ def forget_prefix(prefix): # entries in subdirectories. # def forget_dir(prefix): - if prefix[-1:] = '/' and prefix <> '/': + if prefix[-1:] == '/' and prefix <> '/': prefix = prefix[:-1] forget(prefix) if prefix[-1:] <> '/': prefix = prefix + '/' n = len(prefix) for path in cache.keys(): - if path[:n] = prefix: + if path[:n] == prefix: rest = path[n:] - if rest[-1:] = '/': rest = rest[:-1] + if rest[-1:] == '/': rest = rest[:-1] if '/' not in rest: del cache[path] diff --git a/Lib/stdwin/Buttons.py b/Lib/stdwin/Buttons.py index 949e128..d1435d3 100755 --- a/Lib/stdwin/Buttons.py +++ b/Lib/stdwin/Buttons.py @@ -110,7 +110,7 @@ class LabelAppearance: # def draw(self, (d, area)): area = _rect.intersect(area, self.bounds) - if area = _rect.empty: + if area == _rect.empty: return d.cliprect(area) self.drawit(d) diff --git a/Lib/stdwin/CSplit.py b/Lib/stdwin/CSplit.py index 5c57d90..90d137e 100755 --- a/Lib/stdwin/CSplit.py +++ b/Lib/stdwin/CSplit.py @@ -43,7 +43,7 @@ class CSplit(Split): # XXX One day Python will have automatic conversions... n = len(self.children) fn = float(n) - if n = 0: return + if n == 0: return (left, top), (right, bottom) = bounds width, height = right-left, bottom-top child_width, child_height = width*3/(n+4), height*3/(n+4) diff --git a/Lib/stdwin/DirList.py b/Lib/stdwin/DirList.py index 20a0fe8..0066c58 100755 --- a/Lib/stdwin/DirList.py +++ b/Lib/stdwin/DirList.py @@ -25,7 +25,7 @@ class DirList(VSplit): if path.isdir(path.join(dirname, name)): fullname = path.join(dirname, name) btn = SubdirButton().definetext(self, fullname) - elif name[-3:] = '.py': + elif name[-3:] == '.py': btn = ModuleButton().definetext(self, name) else: btn = FileButton().definetext(self, name) diff --git a/Lib/stdwin/Split.py b/Lib/stdwin/Split.py index b169d72..aacfa98 100755 --- a/Lib/stdwin/Split.py +++ b/Lib/stdwin/Split.py @@ -116,7 +116,7 @@ class Split: if not self.keybd_focus: self.set_keybd_focus(self.keybd_interest[0]) type, detail = type_detail - if type = WE_COMMAND and detail = WC_TAB and \ + if type == WE_COMMAND and detail == WC_TAB and \ len(self.keybd_interest) > 1: self.next_keybd_focus() return @@ -144,9 +144,9 @@ class Split: self.timer_interest.remove(child) if child in self.altdraw_interest: self.altdraw_interest.remove(child) - if child = self.mouse_focus: + if child == self.mouse_focus: self.mouse_focus = None - if child = self.keybd_focus: + if child == self.keybd_focus: self.keybd_focus = None # def need_mouse(self, child): @@ -154,7 +154,7 @@ class Split: self.mouse_interest.append(child) self.parent.need_mouse(self) def no_mouse(self, child): - if child = self.mouse_focus: + if child == self.mouse_focus: self.mouse_focus = None if child in self.mouse_interest: self.mouse_interest.remove(child) @@ -168,7 +168,7 @@ class Split: if not self.keybd_focus: self.set_keybd_focus(child) def no_keybd(self, child): - if child = self.keybd_focus: + if child == self.keybd_focus: self.keybd_focus = None # Don't call child.deactivate() if child in self.keybd_interest: self.keybd_interest.remove(child) diff --git a/Lib/stdwin/StripChart.py b/Lib/stdwin/StripChart.py index d58f835..5bce412 100755 --- a/Lib/stdwin/StripChart.py +++ b/Lib/stdwin/StripChart.py @@ -51,7 +51,7 @@ class StripChart(LabelAppearance, NoReactivity): # def draw(self, (d, area)): area = rect.intersect(area, self.bounds) - if area = rect.empty: + if area == rect.empty: return d.cliprect(area) d.erase(self.bounds) diff --git a/Lib/stdwin/WindowParent.py b/Lib/stdwin/WindowParent.py index a0593c5..697ed07 100755 --- a/Lib/stdwin/WindowParent.py +++ b/Lib/stdwin/WindowParent.py @@ -149,26 +149,26 @@ class WindowParent(ManageOneChild): # Only call dispatch once we are realized # def dispatch(self, (type, win, detail)): - if type = WE_DRAW: + if type == WE_DRAW: d = self.win.begindrawing() self.child.draw(d, detail) del d if self.do_altdraw: self.child.altdraw(detail) - elif type = WE_MOUSE_DOWN: + elif type == WE_MOUSE_DOWN: if self.do_mouse: self.child.mouse_down(detail) - elif type = WE_MOUSE_MOVE: + elif type == WE_MOUSE_MOVE: if self.do_mouse: self.child.mouse_move(detail) - elif type = WE_MOUSE_UP: + elif type == WE_MOUSE_UP: if self.do_mouse: self.child.mouse_up(detail) elif type in (WE_CHAR, WE_COMMAND): if self.do_keybd: self.child.keybd(type, detail) - elif type = WE_TIMER: + elif type == WE_TIMER: if self.do_timer: self.child.timer() - elif type = WE_SIZE: + elif type == WE_SIZE: self.fixup() - elif type = WE_CLOSE: + elif type == WE_CLOSE: self.close_trigger() - elif type = WE_MENU: + elif type == WE_MENU: self.menu_trigger(detail) if self.pending_destroy: self.destroy() diff --git a/Lib/stdwin/WindowSched.py b/Lib/stdwin/WindowSched.py index 9125317..67c3afb 100755 --- a/Lib/stdwin/WindowSched.py +++ b/Lib/stdwin/WindowSched.py @@ -21,7 +21,7 @@ def delayfunc(msecs): # # Use millisleep for very short delays or if there are no windows # - if msecs < 100 or mainloop.countwindows() = 0: + if msecs < 100 or mainloop.countwindows() == 0: if msecs > 0: time.millisleep(msecs) return @@ -46,7 +46,7 @@ cancel = q.cancel # Emptiness check must check both queues # def empty(): - return q.empty() and mainloop.countwindows() = 0 + return q.empty() and mainloop.countwindows() == 0 # Run until there is nothing left to do # diff --git a/Lib/stdwin/dirwin.py b/Lib/stdwin/dirwin.py index d0a8525..beb5222 100755 --- a/Lib/stdwin/dirwin.py +++ b/Lib/stdwin/dirwin.py @@ -10,7 +10,7 @@ import dircache def action(w, string, i, detail): (h, v), clicks, button, mask = detail - if clicks = 2: + if clicks == 2: name = path.join(w.name, string) try: w2 = anywin.open(name) diff --git a/Lib/stdwin/formatter.py b/Lib/stdwin/formatter.py index aea7deb..b2d4add 100755 --- a/Lib/stdwin/formatter.py +++ b/Lib/stdwin/formatter.py @@ -175,20 +175,20 @@ def test(): winsize = w.getwinsize() while 1: type, window, detail = stdwinq.getevent() - if type = WE_CLOSE: + if type == WE_CLOSE: break - elif type = WE_SIZE: + elif type == WE_SIZE: newsize = w.getwinsize() if newsize <> winsize: w.change((0,0), winsize) winsize = newsize w.change((0,0), winsize) - elif type = WE_MOUSE_DOWN: + elif type == WE_MOUSE_DOWN: stage = (stage + 1) % len(stages) justify, center, title = stages[stage] w.settitle(title) w.change((0, 0), (1000, 1000)) - elif type = WE_DRAW: + elif type == WE_DRAW: width, height = winsize f = formatter().init(w.begindrawing(), 0, 0, width) f.center = center @@ -198,7 +198,7 @@ def test(): for font in font1, font2, font1: f.setfont(font) for word in words: - space = 1 + (word[-1:] = '.') + space = 1 + (word[-1:] == '.') f.addword(word, space) if center and space > 1: f.flush() diff --git a/Lib/stdwin/gwin.py b/Lib/stdwin/gwin.py index c2ec11f..12ed90b 100755 --- a/Lib/stdwin/gwin.py +++ b/Lib/stdwin/gwin.py @@ -49,44 +49,44 @@ def mainloop(): # Handle events until no windows left def treatevent(e): # Handle a stdwin event type, w, detail = e - if type = WE_DRAW: + if type == WE_DRAW: w.draw(w, detail) - elif type = WE_MENU: + elif type == WE_MENU: m, item = detail m.action[item](w, m, item) - elif type = WE_COMMAND: + elif type == WE_COMMAND: treatcommand(w, detail) - elif type = WE_CHAR: + elif type == WE_CHAR: w.char(w, detail) - elif type = WE_MOUSE_DOWN: + elif type == WE_MOUSE_DOWN: if detail[1] > 1: w.m2down(w, detail) else: w.mdown(w, detail) - elif type = WE_MOUSE_MOVE: + elif type == WE_MOUSE_MOVE: w.mmove(w, detail) - elif type = WE_MOUSE_UP: + elif type == WE_MOUSE_UP: if detail[1] > 1: w.m2up(w, detail) else: w.mup(w, detail) - elif type = WE_SIZE: + elif type == WE_SIZE: w.size(w, w.getwinsize()) - elif type = WE_ACTIVATE: + elif type == WE_ACTIVATE: w.activate(w) - elif type = WE_DEACTIVATE: + elif type == WE_DEACTIVATE: w.deactivate(w) - elif type = WE_MOVE: + elif type == WE_MOVE: w.move(w) - elif type = WE_TIMER: + elif type == WE_TIMER: w.timer(w) - elif type = WE_CLOSE: + elif type == WE_CLOSE: w.close(w) def treatcommand(w, type): # Handle a we_command event - if type = WC_CLOSE: + if type == WC_CLOSE: w.close(w) - elif type = WC_RETURN: + elif type == WC_RETURN: w.enter(w) - elif type = WC_TAB: + elif type == WC_TAB: w.tab(w) - elif type = WC_BACKSPACE: + elif type == WC_BACKSPACE: w.backspace(w) elif type in (WC_LEFT, WC_UP, WC_RIGHT, WC_DOWN): w.arrow(w, type) @@ -101,13 +101,13 @@ def close(w): # Close method break def arrow(w, detail): # Arrow key method - if detail = WC_LEFT: + if detail == WC_LEFT: w.kleft(w) - elif detail = WC_UP: + elif detail == WC_UP: w.kup(w) - elif detail = WC_RIGHT: + elif detail == WC_RIGHT: w.kright(w) - elif detail = WC_DOWN: + elif detail == WC_DOWN: w.kdown(w) diff --git a/Lib/stdwin/tablewin.py b/Lib/stdwin/tablewin.py index f9ab907..eba161d 100755 --- a/Lib/stdwin/tablewin.py +++ b/Lib/stdwin/tablewin.py @@ -164,13 +164,13 @@ def whichcol(w, h): # Return column number (may be >= len(w.data)) return len(w.data) def arrow(w, type): - if type = WC_LEFT: + if type == WC_LEFT: incr = -1, 0 - elif type = WC_UP: + elif type == WC_UP: incr = 0, -1 - elif type = WC_RIGHT: + elif type == WC_RIGHT: incr = 1, 0 - elif type = WC_DOWN: + elif type == WC_DOWN: incr = 0, 1 else: return diff --git a/Lib/string.py b/Lib/string.py index 1c45ab3..1412048 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -56,7 +56,7 @@ def split(s): i, n = 0, len(s) while i < n: while i < n and s[i] in whitespace: i = i+1 - if i = n: break + if i == n: break j = i while j < n and s[j] not in whitespace: j = j+1 res.append(s[i:j]) @@ -71,7 +71,7 @@ def splitfields(s, sep): nsep = len(sep) i = j = 0 while j+nsep <= ns: - if s[j:j+nsep] = sep: + if s[j:j+nsep] == sep: res.append(s[i:j]) i = j = j + nsep else: @@ -98,7 +98,7 @@ index_error = 'substring not found in string.index' def index(s, sub): n = len(sub) for i in range(len(s) + 1 - n): - if sub = s[i:i+n]: return i + if sub == s[i:i+n]: return i raise index_error, (s, sub) # Convert string to integer @@ -137,7 +137,7 @@ def center(s, width): # Decadent feature: the argument may be a string or a number # (Use of this is deprecated; it should be a string as with ljust c.s.) def zfill(x, width): - if type(x) = type(''): s = x + if type(x) == type(''): s = x else: s = `x` n = len(s) if n >= width: return s diff --git a/Lib/stringold.py b/Lib/stringold.py index 1c45ab3..1412048 100644 --- a/Lib/stringold.py +++ b/Lib/stringold.py @@ -56,7 +56,7 @@ def split(s): i, n = 0, len(s) while i < n: while i < n and s[i] in whitespace: i = i+1 - if i = n: break + if i == n: break j = i while j < n and s[j] not in whitespace: j = j+1 res.append(s[i:j]) @@ -71,7 +71,7 @@ def splitfields(s, sep): nsep = len(sep) i = j = 0 while j+nsep <= ns: - if s[j:j+nsep] = sep: + if s[j:j+nsep] == sep: res.append(s[i:j]) i = j = j + nsep else: @@ -98,7 +98,7 @@ index_error = 'substring not found in string.index' def index(s, sub): n = len(sub) for i in range(len(s) + 1 - n): - if sub = s[i:i+n]: return i + if sub == s[i:i+n]: return i raise index_error, (s, sub) # Convert string to integer @@ -137,7 +137,7 @@ def center(s, width): # Decadent feature: the argument may be a string or a number # (Use of this is deprecated; it should be a string as with ljust c.s.) def zfill(x, width): - if type(x) = type(''): s = x + if type(x) == type(''): s = x else: s = `x` n = len(s) if n >= width: return s diff --git a/Lib/sunaudio.py b/Lib/sunaudio.py index 92a6203..b6e5047 100644 --- a/Lib/sunaudio.py +++ b/Lib/sunaudio.py @@ -44,7 +44,7 @@ def gethdr(fp): def printhdr(file): hdr = gethdr(open(file, 'r')) data_size, encoding, sample_rate, channels, info = hdr - while info[-1:] = '\0': + while info[-1:] == '\0': info = info[:-1] print 'File name: ', file print 'Data size: ', data_size @@ -40,19 +40,19 @@ def browser(tb): break cmd = string.strip(line) if cmd: - if cmd = 'quit': + if cmd == 'quit': break - elif cmd = 'list': + elif cmd == 'list': browserlist(tb) - elif cmd = 'up': + elif cmd == 'up': if ptr-1 >= 0: ptr = ptr-1 else: print 'Bottom of stack.' - elif cmd = 'down': + elif cmd == 'down': if ptr+1 < len(tblist): ptr = ptr+1 else: print 'Top of stack.' - elif cmd = 'locals': + elif cmd == 'locals': printsymbols(tb.tb_frame.f_locals) - elif cmd = 'globals': + elif cmd == 'globals': printsymbols(tb.tb_frame.f_globals) elif cmd in ('?', 'help'): browserhelp() @@ -65,10 +65,10 @@ def browserlist(tb): last = lineno first = max(1, last-10) for i in range(first, last+1): - if i = lineno: prefix = '***' + string.rjust(`i`, 4) + ':' + if i == lineno: prefix = '***' + string.rjust(`i`, 4) + ':' else: prefix = string.rjust(`i`, 7) + ':' line = readfileline(filename, i) - if line[-1:] = '\n': line = line[:-1] + if line[-1:] == '\n': line = line[:-1] print prefix + line def browserexec(tb, cmd): @@ -126,24 +126,24 @@ def printsymbols(d): print def printobject(v, maxlevel): - if v = None: + if v == None: print 'None', elif type(v) in (type(0), type(0.0)): print v, - elif type(v) = type(''): + elif type(v) == type(''): if len(v) > 20: print `v[:17] + '...'`, else: print `v`, - elif type(v) = type(()): + elif type(v) == type(()): print '(', printlist(v, maxlevel) print ')', - elif type(v) = type([]): + elif type(v) == type([]): print '[', printlist(v, maxlevel) print ']', - elif type(v) = type({}): + elif type(v) == type({}): print '{', printdict(v, maxlevel) print '}', @@ -152,7 +152,7 @@ def printobject(v, maxlevel): def printlist(v, maxlevel): n = len(v) - if n = 0: return + if n == 0: return if maxlevel <= 0: print '...', return @@ -164,7 +164,7 @@ def printlist(v, maxlevel): def printdict(v, maxlevel): keys = v.keys() n = len(keys) - if n = 0: return + if n == 0: return if maxlevel <= 0: print '...', return @@ -187,8 +187,8 @@ def readfileline(filename, lineno): cache_ok = 0 if _filecache.has_key(filename): cached_stat, lines = _filecache[filename] - if stat[ST_SIZE] = cached_stat[ST_SIZE] and \ - stat[ST_MTIME] = cached_stat[ST_MTIME]: + if stat[ST_SIZE] == cached_stat[ST_SIZE] and \ + stat[ST_MTIME] == cached_stat[ST_MTIME]: cache_ok = 1 else: print 'Stale cache entry for', filename diff --git a/Lib/test/testall.py b/Lib/test/testall.py index 753e066..5f4a9dc 100644 --- a/Lib/test/testall.py +++ b/Lib/test/testall.py @@ -40,9 +40,13 @@ if 0xff <> 255: raise TestFailed, 'hex number' if 0377 <> 255: raise TestFailed, 'octal number' x = 3.14 x = 0.314 +x = .14 +x = 3. x = 3e14 x = 3E14 x = 3e-14 +x = 3.e14 +x = .14e3 x = 0L x = 0l x = 0xffffffffffffffffL @@ -209,11 +213,11 @@ print 'test' # and_test ('or' and_test)* ### comparison: expr (comp_op expr)* ### comp_op: '<'|'>'|'='|'>' '='|'<' '='|'<' '>'|'in'|'not' 'in'|'is'|'is' 'not' if 1: pass -if 1 = 1: pass -if 1 < 1 > 1 = 1 >= 1 <= 1 <> 1 in 1 not in 1 is 1 is not 1: pass -if not 1 = 1 = 1: pass -if not 1 = 1 and 1 and 1: pass -if 1 and 1 or 1 and 1 and 1 or not 1 = 1 = 1 and 1: pass +if 1 == 1: pass +if 1 < 1 > 1 == 1 >= 1 <= 1 <> 1 in 1 not in 1 is 1 is not 1: pass +if not 1 == 1 == 1: pass +if not 1 == 1 and 1 and 1: pass +if 1 and 1 or 1 and 1 and 1 or not 1 == 1 == 1 and 1: pass print 'expr' # term (('+'|'-') term)* x = 1 @@ -236,17 +240,34 @@ x = 1 c = sys.path[0] x = time.time() x = sys.modules['time'].time() -a = '01234' -c = a[0] -c = a[0:5] -c = a[:5] -c = a[0:] -c = a[:] -c = a[-5:] -c = a[:-1] -c = a[-4:-3] - -print 'atom' # '(' [testlist] ')' | '[' [testlist] ']' | '{' '}' | '`' testlist '`' | NAME | NUMBER | STRING +for a in '01234', (0,1,2,3,4), [0,1,2,3,4]: + c = a[0] + c = a[-1] + c = a[0:5] + c = a[:5] + c = a[0:] + c = a[:] + c = a[-5:] + c = a[:-1] + c = a[-4:-3] +a = [0,1,2,3,4] +del a[0] +a = [0,1,2,3,4] +del a[-1] +a = [0,1,2,3,4] +del a[1:2] +a = [0,1,2,3,4] +del a[:1] +a = [0,1,2,3,4] +del a[-1:] +a = [0,1,2,3,4] +a[0] = 0 +a[-1] = 4 +a[1:2] = [1] +a[1:4] = [0] +a[1:-1] = [1,2,3] + +print 'atom' # '(' [tetslist] ')' | '[' [testlist] ']' | '{' '}' | '`' testlist '`' | NAME | NUMBER | STRING x = (1) x = (1 or 2 or 3) x = (1 or 2 or 3, 2, 3) @@ -476,7 +497,7 @@ import string reload(string) print 'type' -if type('') <> type('123') or type('') = type(()): +if type('') <> type('123') or type('') == type(()): raise TestFailed, 'type()' diff --git a/Lib/zmod.py b/Lib/zmod.py index d7f06db..4f03626 100644 --- a/Lib/zmod.py +++ b/Lib/zmod.py @@ -53,7 +53,7 @@ def make_all(mat): return all def make_elements(n, d): - if d = 0: return [poly.one(0, 0)] + if d == 0: return [poly.one(0, 0)] sub = make_elements(n, d-1) all = [] for a in sub: @@ -75,7 +75,7 @@ def checkfield(n, p): inv1 = inv[:] all1.sort() inv1.sort() - if all1 = inv1: print 'BINGO!' + if all1 == inv1: print 'BINGO!' else: print 'Sorry:', n, p print all diff --git a/Mac/Lib/maccache.py b/Mac/Lib/maccache.py index 47b673c..725f10e 100644 --- a/Mac/Lib/maccache.py +++ b/Mac/Lib/maccache.py @@ -37,17 +37,17 @@ def _stat(name): cache[name] = NONE return NONE cache[name] = list - if name[-1:] = ':': cache[name[:-1]] = list + if name[-1:] == ':': cache[name[:-1]] = list else: cache[name+':'] = list return list def isdir(name): st = _stat(name) - return type(st) = LISTTYPE + return type(st) == LISTTYPE def isfile(name): st = _stat(name) - return st = FILE + return st == FILE def exists(name): st = _stat(name) @@ -55,7 +55,7 @@ def exists(name): def listdir(name): st = _stat(name) - if type(st) = LISTTYPE: + if type(st) == LISTTYPE: return st else: raise RuntimeError, 'list non-directory' diff --git a/Tools/scripts/byteyears.py b/Tools/scripts/byteyears.py index 06f7559..c0aea70 100755 --- a/Tools/scripts/byteyears.py +++ b/Tools/scripts/byteyears.py @@ -17,13 +17,13 @@ except NameError: statfunc = posix.stat # Parse options -if sys.argv[1] = '-m': +if sys.argv[1] == '-m': itime = ST_MTIME del sys.argv[1] -elif sys.argv[1] = '-c': +elif sys.argv[1] == '-c': itime = ST_CTIME del sys.argv[1] -elif sys.argv[1] = '-a': +elif sys.argv[1] == '-a': itime = ST_CTIME del sys.argv[1] else: diff --git a/Tools/scripts/checkpyc.py b/Tools/scripts/checkpyc.py index 152fb1d..54396a3 100755 --- a/Tools/scripts/checkpyc.py +++ b/Tools/scripts/checkpyc.py @@ -10,9 +10,9 @@ def main(): silent = 0 verbose = 0 if sys.argv[1:]: - if sys.argv[1] = '-v': + if sys.argv[1] == '-v': verbose = 1 - elif sys.argv[1] = '-s': + elif sys.argv[1] == '-s': silent = 1 MAGIC = '\0\0\0\0' try: @@ -32,7 +32,7 @@ def main(): print 'Checking', `dirname`, '...' names.sort() for name in names: - if name[-3:] = '.py': + if name[-3:] == '.py': name = path.join(dirname, name) try: st = posix.stat(name) @@ -55,7 +55,7 @@ def main(): print `name_c` continue mtime = get_long(mtime_str) - if mtime = 0 or mtime = -1: + if mtime == 0 or mtime == -1: print 'Bad ".pyc" file', `name_c` elif mtime <> st[ST_MTIME]: print 'Out-of-date ".pyc" file', diff --git a/Tools/scripts/findlinksto.py b/Tools/scripts/findlinksto.py index 9398514..a8051c1 100755 --- a/Tools/scripts/findlinksto.py +++ b/Tools/scripts/findlinksto.py @@ -17,7 +17,7 @@ def visit(pattern, dirname, names): name = path.join(dirname, name) try: linkto = posix.readlink(name) - if linkto[:n] = pattern: + if linkto[:n] == pattern: print name, '->', linkto except posix.error: pass diff --git a/Tools/scripts/objgraph.py b/Tools/scripts/objgraph.py index b45bba2..a21797d 100755 --- a/Tools/scripts/objgraph.py +++ b/Tools/scripts/objgraph.py @@ -170,18 +170,18 @@ def main(): return 1 optu = optc = optd = 0 for opt, void in optlist: - if opt = '-u': + if opt == '-u': optu = 1 - elif opt = '-c': + elif opt == '-c': optc = 1 - elif opt = '-d': + elif opt == '-d': optd = 1 - if optu = optc = optd = 0: + if optu == optc == optd == 0: optu = optc = optd = 1 if not args: args = ['-'] for file in args: - if file = '-': + if file == '-': readinput(sys.stdin) else: readinput(open(file, 'r')) diff --git a/Tools/scripts/pdeps.py b/Tools/scripts/pdeps.py index 2533015..df20894 100755 --- a/Tools/scripts/pdeps.py +++ b/Tools/scripts/pdeps.py @@ -67,13 +67,13 @@ m_from = regexp.compile('^[ \t]*import[ \t]+([^#]+)') def process(filename, table): fp = open(filename, 'r') mod = path.basename(filename) - if mod[-3:] = '.py': + if mod[-3:] == '.py': mod = mod[:-3] table[mod] = list = [] while 1: line = fp.readline() if not line: break - while line[-1:] = '\\': + while line[-1:] == '\\': nextline = fp.readline() if not nextline: break line = line[:-1] + nextline diff --git a/Tools/scripts/ptags.py b/Tools/scripts/ptags.py index b3a693e..fdf7bd1 100755 --- a/Tools/scripts/ptags.py +++ b/Tools/scripts/ptags.py @@ -33,7 +33,7 @@ def treat_file(file): print 'Cannot open', file return base = path.basename(file) - if base[-3:] = '.py': base = base[:-3] + if base[-3:] == '.py': base = base[:-3] s = base + '\t' + file + '\t' + '1\n' tags.append(s) while 1: diff --git a/Tools/scripts/suff.py b/Tools/scripts/suff.py index 7fda113..a92557c 100755 --- a/Tools/scripts/suff.py +++ b/Tools/scripts/suff.py @@ -22,7 +22,7 @@ def main(): def getsuffix(file): suff = '' for i in range(len(file)): - if file[i] = '.': + if file[i] == '.': suff = file[i:] return suff diff --git a/Tools/scripts/which.py b/Tools/scripts/which.py index b36c5ca..24071f4 100755 --- a/Tools/scripts/which.py +++ b/Tools/scripts/which.py @@ -23,7 +23,7 @@ for prog in sys.argv[1:]: mode = S_IMODE(st[ST_MODE]) if mode % 2 or mode/8 % 2 or mode/64 % 2: if ident: - if st[:3] = ident: + if st[:3] == ident: s = ': same as ' else: s = ': also ' diff --git a/Tools/scripts/xxci.py b/Tools/scripts/xxci.py index ef4ff11..27bb71d 100755 --- a/Tools/scripts/xxci.py +++ b/Tools/scripts/xxci.py @@ -50,19 +50,19 @@ def skipfile(file): # Skip executables try: data = open(file, 'r').read(len(EXECMAGIC)) - if data = EXECMAGIC: return 1 + if data == EXECMAGIC: return 1 except: pass return 0 def badprefix(file): for bad in badprefixes: - if file[:len(bad)] = bad: return 1 + if file[:len(bad)] == bad: return 1 return 0 def badsuffix(file): for bad in badsuffixes: - if file[-len(bad):] = bad: return 1 + if file[-len(bad):] == bad: return 1 return 0 def go(args): |