diff options
author | Fred Drake <fdrake@acm.org> | 2000-12-12 23:11:42 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-12-12 23:11:42 (GMT) |
commit | 132dce22469f476f399d1bbc6d1cc2f7ba0110cc (patch) | |
tree | 4b0988e41b3b7d25d10c2a24fb18b07ff376f66d /Lib/lib-old | |
parent | 63596aeb33c2837d7802449c8906349c9ea1998e (diff) | |
download | cpython-132dce22469f476f399d1bbc6d1cc2f7ba0110cc.zip cpython-132dce22469f476f399d1bbc6d1cc2f7ba0110cc.tar.gz cpython-132dce22469f476f399d1bbc6d1cc2f7ba0110cc.tar.bz2 |
Update the code to better reflect recommended style:
Use != instead of <> since <> is documented as "obsolescent".
Use "is" and "is not" when comparing with None or type objects.
Diffstat (limited to 'Lib/lib-old')
-rw-r--r-- | Lib/lib-old/Para.py | 36 | ||||
-rw-r--r-- | Lib/lib-old/cmp.py | 6 | ||||
-rw-r--r-- | Lib/lib-old/cmpcache.py | 4 | ||||
-rw-r--r-- | Lib/lib-old/dircmp.py | 5 | ||||
-rw-r--r-- | Lib/lib-old/fmt.py | 24 | ||||
-rw-r--r-- | Lib/lib-old/grep.py | 2 | ||||
-rw-r--r-- | Lib/lib-old/packmail.py | 2 | ||||
-rw-r--r-- | Lib/lib-old/tb.py | 16 | ||||
-rw-r--r-- | Lib/lib-old/zmod.py | 4 |
9 files changed, 50 insertions, 49 deletions
diff --git a/Lib/lib-old/Para.py b/Lib/lib-old/Para.py index bf5f92c..2e6aa4c 100644 --- a/Lib/lib-old/Para.py +++ b/Lib/lib-old/Para.py @@ -28,7 +28,7 @@ class Para: # Each word should be a 7-tuple: # (font, text, width, space, stretch, ascent, descent) def addword(self, d, font, text, space, stretch): - if font <> None: + if font is not None: d.setfont(font) width = d.textwidth(text) ascent = d.baseline() @@ -50,7 +50,7 @@ class Para: def getlength(self): total = 0 for word in self.words: - if type(word) <> Int: + if type(word) is not Int: total = total + word[2] + word[3] return total # @@ -63,7 +63,7 @@ class Para: as, de = 1, 0 for i in range(len(self.words)): word = self.words[i] - if type(word) == Int: continue + if type(word) is Int: continue (fo, te, wi, sp, st, as, de) = word self.words[i] = (fo, te, wi, sp, 0, as, de) total = total + wi + sp @@ -99,7 +99,7 @@ class Para: j = i while i < n: word = words[i] - if type(word) == Int: + if type(word) is Int: if word > 0 and width >= avail: break i = i+1 @@ -107,7 +107,7 @@ class Para: fo, te, wi, sp, st, as, de = word if width + wi > avail and width > 0 and wi > 0: break - if fo <> None: + if fo is not None: lastfont = fo if width == 0: firstfont = fo @@ -119,7 +119,7 @@ class Para: ascent = max(ascent, as) descent = max(descent, de) i = i+1 - while i > j and type(words[i-1]) == Int and \ + while i > j and type(words[i-1]) is Int and \ words[i-1] > 0: i = i-1 width = width - lsp if i < n: @@ -152,10 +152,10 @@ class Para: v2 = v + ascent + descent for j in range(i, i+wordcount): word = self.words[j] - if type(word) == Int: + if type(word) is Int: ok = anchorfunc(self, tuple, word, \ h, v) - if ok <> None: return ok + if ok is not None: return ok continue fo, te, wi, sp, st, as, de = word if extra > 0 and stretch > 0: @@ -167,7 +167,7 @@ class Para: h2 = h + wi + sp + ex ok = wordfunc(self, tuple, word, h, v, \ h2, v2, (j==i), (j==i+wordcount-1)) - if ok <> None: return ok + if ok is not None: return ok h = h2 v = v2 i = i + wordcount @@ -177,7 +177,7 @@ class Para: # given by (left, top, right) with an unspecified bottom. # Return the computed bottom of the text. def render(self, d, left, top, right): - if self.width <> right-left: + if self.width != right-left: self.layout(right-left) self.left = left self.top = top @@ -193,7 +193,7 @@ class Para: return self.bottom # def _renderword(self, tuple, word, h, v, h2, v2, isfirst, islast): - if word[0] <> None: self.d.setfont(word[0]) + if word[0] is not None: self.d.setfont(word[0]) baseline = v + tuple[5] self.d.text((h, baseline - word[5]), word[1]) if self.anchorid > 0: @@ -229,7 +229,7 @@ class Para: def extract(self): text = '' for w in self.words: - if type(w) <> Int: + if type(w) is not Int: word = w[1] if w[3]: word = word + ' ' text = text + word @@ -254,14 +254,14 @@ class Para: # def _whereisword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): fo, te, wi, sp, st, as, de = word - if fo <> None: self.lastfont = fo + if fo is not None: self.lastfont = fo h = h1 if isfirst: h1 = 0 if islast: h2 = 999999 if not (v1 <= self.mousev <= v2 and h1 <= self.mouseh <= h2): self.charcount = self.charcount + len(te) + (sp > 0) return - if self.lastfont <> None: + if self.lastfont is not None: self.d.setfont(self.lastfont) cc = 0 for c in te: @@ -295,7 +295,7 @@ class Para: self.__class__._screenposanchor) finally: self.d = None - if ok == None: + if ok is None: ascent, descent = self.lines[-1][5:7] ok = self.right, self.bottom - ascent - descent, \ self.bottom - descent, self.bottom @@ -303,7 +303,7 @@ class Para: # def _screenposword(self, tuple, word, h1, v1, h2, v2, isfirst, islast): fo, te, wi, sp, st, as, de = word - if fo <> None: self.lastfont = fo + if fo is not None: self.lastfont = fo cc = len(te) + (sp > 0) if self.pos > cc: self.pos = self.pos - cc @@ -324,11 +324,11 @@ class Para: # if pos2 is None, the end is implied. # Undoes its own effect when called again with the same arguments def invert(self, d, pos1, pos2): - if pos1 == None: + if pos1 is None: pos1 = self.left, self.top, self.top, self.top else: pos1 = self.screenpos(d, pos1) - if pos2 == None: + if pos2 is None: pos2 = self.right, self.bottom,self.bottom,self.bottom else: pos2 = self.screenpos(d, pos2) diff --git a/Lib/lib-old/cmp.py b/Lib/lib-old/cmp.py index 943d8bd..1146a25 100644 --- a/Lib/lib-old/cmp.py +++ b/Lib/lib-old/cmp.py @@ -16,13 +16,13 @@ def cmp(f1, f2, shallow=1): Return 1 for identical files, 0 for different. Raise exceptions if either file could not be statted, read, etc.""" s1, s2 = sig(os.stat(f1)), sig(os.stat(f2)) - if s1[0] <> 8 or s2[0] <> 8: + if s1[0] != 8 or s2[0] != 8: # Either is a not a plain file -- always report as different return 0 if shallow and s1 == s2: # type, size & mtime match -- report same return 1 - if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother + if s1[:2] != s2[:2]: # Types or sizes differ, don't bother # types or sizes differ -- report different return 0 # same type and size -- look in the cache @@ -59,5 +59,5 @@ def do_cmp(f1, f2): while 1: b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) - if b1 <> b2: return 0 + if b1 != b2: return 0 if not b1: return 1 diff --git a/Lib/lib-old/cmpcache.py b/Lib/lib-old/cmpcache.py index 93332b7..11540f8 100644 --- a/Lib/lib-old/cmpcache.py +++ b/Lib/lib-old/cmpcache.py @@ -30,7 +30,7 @@ def cmp(f1, f2, shallow=1): if shallow and s1 == s2: # type, size & mtime match -- report same return 1 - if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother + if s1[:2] != s2[:2]: # Types or sizes differ, don't bother # types or sizes differ -- report different return 0 # same type and size -- look in the cache @@ -60,5 +60,5 @@ def do_cmp(f1, f2): while 1: b1 = fp1.read(bufsize) b2 = fp2.read(bufsize) - if b1 <> b2: return 0 + if b1 != b2: return 0 if not b1: return 1 diff --git a/Lib/lib-old/dircmp.py b/Lib/lib-old/dircmp.py index 13a8a04..1e7bf2a 100644 --- a/Lib/lib-old/dircmp.py +++ b/Lib/lib-old/dircmp.py @@ -70,7 +70,7 @@ class dircmp: if ok: a_type = S_IFMT(a_stat[ST_MODE]) b_type = S_IFMT(b_stat[ST_MODE]) - if a_type <> b_type: + if a_type != b_type: self.common_funny.append(x) elif S_ISDIR(a_type): self.common_dirs.append(x) @@ -189,7 +189,8 @@ def demo(): import sys import getopt options, args = getopt.getopt(sys.argv[1:], 'r') - if len(args) <> 2: raise getopt.error, 'need exactly two args' + if len(args) != 2: + raise getopt.error, 'need exactly two args' dd = dircmp().new(args[0], args[1]) dd.run() if ('-r', '') in options: diff --git a/Lib/lib-old/fmt.py b/Lib/lib-old/fmt.py index 86671cd..dfea987 100644 --- a/Lib/lib-old/fmt.py +++ b/Lib/lib-old/fmt.py @@ -68,20 +68,20 @@ class SavingBackEnd(NullBackEnd): for i in range(len(self.paralist)): p = self.paralist[i] result = p.whereis(d, h, v) - if result <> None: + if result is not None: return i, result return None # def roundtowords(self, long1, long2): i, offset = long1 text = self.paralist[i].extract() - while offset > 0 and text[offset-1] <> ' ': offset = offset-1 + while offset > 0 and text[offset-1] != ' ': offset = offset-1 long1 = i, offset # i, offset = long2 text = self.paralist[i].extract() n = len(text) - while offset < n-1 and text[offset] <> ' ': offset = offset+1 + while offset < n-1 and text[offset] != ' ': offset = offset+1 long2 = i, offset # return long1, long2 @@ -159,7 +159,7 @@ class BaseFormatter: return Para.Para() # def setfont(self, font): - if font == None: return + if font is None: return self.font = self.nextfont = font d = self.d d.setfont(font) @@ -193,7 +193,7 @@ class BaseFormatter: if self.para: self.b.addpara(self.para) self.para = None - if self.font <> None: + if self.font is not None: self.d.setfont(self.font) self.nospace = 1 # @@ -338,8 +338,8 @@ def finalize(para): para.words.append(('r', '', 0, 0, 0, 0)) # temporary, deleted at end for i in range(len(para.words)): fo, te, wi = para.words[i][:3] - if fo <> None: curfont = fo - if curfont <> oldfont: + if fo is not None: curfont = fo + if curfont != oldfont: if closechar.has_key(oldfont): c = closechar[oldfont] j = i-1 @@ -430,7 +430,7 @@ class StdwinBackEnd(SavingBackEnd): pos1 = long1[:3] pos2 = long2[:3] new = pos1, pos2 - if new <> self.selection: + if new != self.selection: d = self.window.begindrawing() if self.selection: self.invert(d, self.selection) @@ -462,7 +462,7 @@ class StdwinBackEnd(SavingBackEnd): # def search(self, prog): import re, string - if type(prog) == type(''): + if type(prog) is type(''): prog = re.compile(string.lower(prog)) if self.selection: iold = self.selection[0][0] @@ -551,7 +551,7 @@ class GLFontCache: self.fontcache[fontkey] = \ self.fontcache[key] = handle self.fontkey = fontkey - if self.fonthandle <> handle: + if self.fonthandle != handle: self.fonthandle = handle self.fontinfo = handle.getfontinfo() handle.setfont() @@ -582,7 +582,7 @@ class GLWriter(GLFontCache): def setfont(self, fontkey): oldhandle = self.fonthandle GLFontCache.setfont(fontkey) - if self.fonthandle <> oldhandle: + if self.fonthandle != oldhandle: handle.setfont() @@ -612,7 +612,7 @@ class GLBackEnd(SavingBackEnd): import gl gl.winset(self.wid) width = gl.getsize()[1] - if width <> self.width: + if width != self.width: setdocsize = 1 self.width = width for p in self.paralist: diff --git a/Lib/lib-old/grep.py b/Lib/lib-old/grep.py index 423c065..6f74fd3 100644 --- a/Lib/lib-old/grep.py +++ b/Lib/lib-old/grep.py @@ -73,7 +73,7 @@ def showline(filename, lineno, line, prog): else: prefix = ' ' * len(prefix) for c in line: - if c <> '\t': c = ' ' + if c != '\t': c = ' ' prefix = prefix + c if start == end: prefix = prefix + '\\' else: prefix = prefix + '^'*(end-start) diff --git a/Lib/lib-old/packmail.py b/Lib/lib-old/packmail.py index 4541c51..2a5aa75 100644 --- a/Lib/lib-old/packmail.py +++ b/Lib/lib-old/packmail.py @@ -25,7 +25,7 @@ def pack(outfp, file, name): while 1: line = fp.readline() if not line: break - if line[-1:] <> '\n': + if line[-1:] != '\n': line = line + '\n' outfp.write('X' + line) outfp.write('!\n') diff --git a/Lib/lib-old/tb.py b/Lib/lib-old/tb.py index 5c592ce..abe4824 100644 --- a/Lib/lib-old/tb.py +++ b/Lib/lib-old/tb.py @@ -23,7 +23,7 @@ def browser(tb): ptr = len(tblist)-1 tb = tblist[ptr] while 1: - if tb <> tblist[ptr]: + if tb != tblist[ptr]: tb = tblist[ptr] print `ptr` + ':', printtbheader(tb) @@ -76,11 +76,11 @@ def browserexec(tb, cmd): except: t, v = sys.exc_info()[:2] print '*** Exception:', - if type(t) == type(''): + if type(t) is type(''): print t, else: print t.__name__, - if v <> None: + if v is not None: print ':', v, print print 'Type help to get help.' @@ -127,24 +127,24 @@ def printsymbols(d): print def printobject(v, maxlevel): - if v == None: + if v is None: print 'None', elif type(v) in (type(0), type(0.0)): print v, - elif type(v) == type(''): + elif type(v) is type(''): if len(v) > 20: print `v[:17] + '...'`, else: print `v`, - elif type(v) == type(()): + elif type(v) is type(()): print '(', printlist(v, maxlevel) print ')', - elif type(v) == type([]): + elif type(v) is type([]): print '[', printlist(v, maxlevel) print ']', - elif type(v) == type({}): + elif type(v) is type({}): print '{', printdict(v, maxlevel) print '}', diff --git a/Lib/lib-old/zmod.py b/Lib/lib-old/zmod.py index 4f03626..7259bf8 100644 --- a/Lib/lib-old/zmod.py +++ b/Lib/lib-old/zmod.py @@ -82,13 +82,13 @@ def checkfield(n, p): print inv def rj(s, width): - if type(s) <> type(''): s = `s` + if type(s) is not type(''): s = `s` n = len(s) if n >= width: return s return ' '*(width - n) + s def lj(s, width): - if type(s) <> type(''): s = `s` + if type(s) is not type(''): s = `s` n = len(s) if n >= width: return s return s + ' '*(width - n) |