Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 132dce2

Browse files
committed
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.
1 parent 63596ae commit 132dce2

55 files changed

Lines changed: 520 additions & 519 deletions

Some content is hidden

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

Lib/distutils/cygwinccompiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def link (self,
241241
objects.append(def_file)
242242

243243
#end: if ((export_symbols is not None) and
244-
# (target_desc <> self.EXECUTABLE or self.linker_dll == "gcc")):
244+
# (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")):
245245

246246
# who wants symbols and a many times larger output file
247247
# should explicitly switch the debug mode on

Lib/lib-old/Para.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self):
2828
# Each word should be a 7-tuple:
2929
# (font, text, width, space, stretch, ascent, descent)
3030
def addword(self, d, font, text, space, stretch):
31-
if font <> None:
31+
if font is not None:
3232
d.setfont(font)
3333
width = d.textwidth(text)
3434
ascent = d.baseline()
@@ -50,7 +50,7 @@ def end_anchor(self, id):
5050
def getlength(self):
5151
total = 0
5252
for word in self.words:
53-
if type(word) <> Int:
53+
if type(word) is not Int:
5454
total = total + word[2] + word[3]
5555
return total
5656
#
@@ -63,7 +63,7 @@ def tabto(self, tab):
6363
as, de = 1, 0
6464
for i in range(len(self.words)):
6565
word = self.words[i]
66-
if type(word) == Int: continue
66+
if type(word) is Int: continue
6767
(fo, te, wi, sp, st, as, de) = word
6868
self.words[i] = (fo, te, wi, sp, 0, as, de)
6969
total = total + wi + sp
@@ -99,15 +99,15 @@ def layout(self, linewidth):
9999
j = i
100100
while i < n:
101101
word = words[i]
102-
if type(word) == Int:
102+
if type(word) is Int:
103103
if word > 0 and width >= avail:
104104
break
105105
i = i+1
106106
continue
107107
fo, te, wi, sp, st, as, de = word
108108
if width + wi > avail and width > 0 and wi > 0:
109109
break
110-
if fo <> None:
110+
if fo is not None:
111111
lastfont = fo
112112
if width == 0:
113113
firstfont = fo
@@ -119,7 +119,7 @@ def layout(self, linewidth):
119119
ascent = max(ascent, as)
120120
descent = max(descent, de)
121121
i = i+1
122-
while i > j and type(words[i-1]) == Int and \
122+
while i > j and type(words[i-1]) is Int and \
123123
words[i-1] > 0: i = i-1
124124
width = width - lsp
125125
if i < n:
@@ -152,10 +152,10 @@ def visit(self, wordfunc, anchorfunc):
152152
v2 = v + ascent + descent
153153
for j in range(i, i+wordcount):
154154
word = self.words[j]
155-
if type(word) == Int:
155+
if type(word) is Int:
156156
ok = anchorfunc(self, tuple, word, \
157157
h, v)
158-
if ok <> None: return ok
158+
if ok is not None: return ok
159159
continue
160160
fo, te, wi, sp, st, as, de = word
161161
if extra > 0 and stretch > 0:
@@ -167,7 +167,7 @@ def visit(self, wordfunc, anchorfunc):
167167
h2 = h + wi + sp + ex
168168
ok = wordfunc(self, tuple, word, h, v, \
169169
h2, v2, (j==i), (j==i+wordcount-1))
170-
if ok <> None: return ok
170+
if ok is not None: return ok
171171
h = h2
172172
v = v2
173173
i = i + wordcount
@@ -177,7 +177,7 @@ def visit(self, wordfunc, anchorfunc):
177177
# given by (left, top, right) with an unspecified bottom.
178178
# Return the computed bottom of the text.
179179
def render(self, d, left, top, right):
180-
if self.width <> right-left:
180+
if self.width != right-left:
181181
self.layout(right-left)
182182
self.left = left
183183
self.top = top
@@ -193,7 +193,7 @@ def render(self, d, left, top, right):
193193
return self.bottom
194194
#
195195
def _renderword(self, tuple, word, h, v, h2, v2, isfirst, islast):
196-
if word[0] <> None: self.d.setfont(word[0])
196+
if word[0] is not None: self.d.setfont(word[0])
197197
baseline = v + tuple[5]
198198
self.d.text((h, baseline - word[5]), word[1])
199199
if self.anchorid > 0:
@@ -229,7 +229,7 @@ def hasanchor(self, id):
229229
def extract(self):
230230
text = ''
231231
for w in self.words:
232-
if type(w) <> Int:
232+
if type(w) is not Int:
233233
word = w[1]
234234
if w[3]: word = word + ' '
235235
text = text + word
@@ -254,14 +254,14 @@ def whereis(self, d, mouseh, mousev):
254254
#
255255
def _whereisword(self, tuple, word, h1, v1, h2, v2, isfirst, islast):
256256
fo, te, wi, sp, st, as, de = word
257-
if fo <> None: self.lastfont = fo
257+
if fo is not None: self.lastfont = fo
258258
h = h1
259259
if isfirst: h1 = 0
260260
if islast: h2 = 999999
261261
if not (v1 <= self.mousev <= v2 and h1 <= self.mouseh <= h2):
262262
self.charcount = self.charcount + len(te) + (sp > 0)
263263
return
264-
if self.lastfont <> None:
264+
if self.lastfont is not None:
265265
self.d.setfont(self.lastfont)
266266
cc = 0
267267
for c in te:
@@ -295,15 +295,15 @@ def screenpos(self, d, pos):
295295
self.__class__._screenposanchor)
296296
finally:
297297
self.d = None
298-
if ok == None:
298+
if ok is None:
299299
ascent, descent = self.lines[-1][5:7]
300300
ok = self.right, self.bottom - ascent - descent, \
301301
self.bottom - descent, self.bottom
302302
return ok
303303
#
304304
def _screenposword(self, tuple, word, h1, v1, h2, v2, isfirst, islast):
305305
fo, te, wi, sp, st, as, de = word
306-
if fo <> None: self.lastfont = fo
306+
if fo is not None: self.lastfont = fo
307307
cc = len(te) + (sp > 0)
308308
if self.pos > cc:
309309
self.pos = self.pos - cc
@@ -324,11 +324,11 @@ def _screenposanchor(self, tuple, word, h, v):
324324
# if pos2 is None, the end is implied.
325325
# Undoes its own effect when called again with the same arguments
326326
def invert(self, d, pos1, pos2):
327-
if pos1 == None:
327+
if pos1 is None:
328328
pos1 = self.left, self.top, self.top, self.top
329329
else:
330330
pos1 = self.screenpos(d, pos1)
331-
if pos2 == None:
331+
if pos2 is None:
332332
pos2 = self.right, self.bottom,self.bottom,self.bottom
333333
else:
334334
pos2 = self.screenpos(d, pos2)

Lib/lib-old/cmp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ def cmp(f1, f2, shallow=1):
1616
Return 1 for identical files, 0 for different.
1717
Raise exceptions if either file could not be statted, read, etc."""
1818
s1, s2 = sig(os.stat(f1)), sig(os.stat(f2))
19-
if s1[0] <> 8 or s2[0] <> 8:
19+
if s1[0] != 8 or s2[0] != 8:
2020
# Either is a not a plain file -- always report as different
2121
return 0
2222
if shallow and s1 == s2:
2323
# type, size & mtime match -- report same
2424
return 1
25-
if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
25+
if s1[:2] != s2[:2]: # Types or sizes differ, don't bother
2626
# types or sizes differ -- report different
2727
return 0
2828
# same type and size -- look in the cache
@@ -59,5 +59,5 @@ def do_cmp(f1, f2):
5959
while 1:
6060
b1 = fp1.read(bufsize)
6161
b2 = fp2.read(bufsize)
62-
if b1 <> b2: return 0
62+
if b1 != b2: return 0
6363
if not b1: return 1

Lib/lib-old/cmpcache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def cmp(f1, f2, shallow=1):
3030
if shallow and s1 == s2:
3131
# type, size & mtime match -- report same
3232
return 1
33-
if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
33+
if s1[:2] != s2[:2]: # Types or sizes differ, don't bother
3434
# types or sizes differ -- report different
3535
return 0
3636
# same type and size -- look in the cache
@@ -60,5 +60,5 @@ def do_cmp(f1, f2):
6060
while 1:
6161
b1 = fp1.read(bufsize)
6262
b2 = fp2.read(bufsize)
63-
if b1 <> b2: return 0
63+
if b1 != b2: return 0
6464
if not b1: return 1

Lib/lib-old/dircmp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def phase2(self):
7070
if ok:
7171
a_type = S_IFMT(a_stat[ST_MODE])
7272
b_type = S_IFMT(b_stat[ST_MODE])
73-
if a_type <> b_type:
73+
if a_type != b_type:
7474
self.common_funny.append(x)
7575
elif S_ISDIR(a_type):
7676
self.common_dirs.append(x)
@@ -189,7 +189,8 @@ def demo():
189189
import sys
190190
import getopt
191191
options, args = getopt.getopt(sys.argv[1:], 'r')
192-
if len(args) <> 2: raise getopt.error, 'need exactly two args'
192+
if len(args) != 2:
193+
raise getopt.error, 'need exactly two args'
193194
dd = dircmp().new(args[0], args[1])
194195
dd.run()
195196
if ('-r', '') in options:

Lib/lib-old/fmt.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ def whereis(self, d, h, v):
6868
for i in range(len(self.paralist)):
6969
p = self.paralist[i]
7070
result = p.whereis(d, h, v)
71-
if result <> None:
71+
if result is not None:
7272
return i, result
7373
return None
7474
#
7575
def roundtowords(self, long1, long2):
7676
i, offset = long1
7777
text = self.paralist[i].extract()
78-
while offset > 0 and text[offset-1] <> ' ': offset = offset-1
78+
while offset > 0 and text[offset-1] != ' ': offset = offset-1
7979
long1 = i, offset
8080
#
8181
i, offset = long2
8282
text = self.paralist[i].extract()
8383
n = len(text)
84-
while offset < n-1 and text[offset] <> ' ': offset = offset+1
84+
while offset < n-1 and text[offset] != ' ': offset = offset+1
8585
long2 = i, offset
8686
#
8787
return long1, long2
@@ -159,7 +159,7 @@ def newpara(self):
159159
return Para.Para()
160160
#
161161
def setfont(self, font):
162-
if font == None: return
162+
if font is None: return
163163
self.font = self.nextfont = font
164164
d = self.d
165165
d.setfont(font)
@@ -193,7 +193,7 @@ def flush(self):
193193
if self.para:
194194
self.b.addpara(self.para)
195195
self.para = None
196-
if self.font <> None:
196+
if self.font is not None:
197197
self.d.setfont(self.font)
198198
self.nospace = 1
199199
#
@@ -338,8 +338,8 @@ def finalize(para):
338338
para.words.append(('r', '', 0, 0, 0, 0)) # temporary, deleted at end
339339
for i in range(len(para.words)):
340340
fo, te, wi = para.words[i][:3]
341-
if fo <> None: curfont = fo
342-
if curfont <> oldfont:
341+
if fo is not None: curfont = fo
342+
if curfont != oldfont:
343343
if closechar.has_key(oldfont):
344344
c = closechar[oldfont]
345345
j = i-1
@@ -430,7 +430,7 @@ def setselection(self, new):
430430
pos1 = long1[:3]
431431
pos2 = long2[:3]
432432
new = pos1, pos2
433-
if new <> self.selection:
433+
if new != self.selection:
434434
d = self.window.begindrawing()
435435
if self.selection:
436436
self.invert(d, self.selection)
@@ -462,7 +462,7 @@ def invert(self, d, region):
462462
#
463463
def search(self, prog):
464464
import re, string
465-
if type(prog) == type(''):
465+
if type(prog) is type(''):
466466
prog = re.compile(string.lower(prog))
467467
if self.selection:
468468
iold = self.selection[0][0]
@@ -551,7 +551,7 @@ def setfont(self, fontkey):
551551
self.fontcache[fontkey] = \
552552
self.fontcache[key] = handle
553553
self.fontkey = fontkey
554-
if self.fonthandle <> handle:
554+
if self.fonthandle != handle:
555555
self.fonthandle = handle
556556
self.fontinfo = handle.getfontinfo()
557557
handle.setfont()
@@ -582,7 +582,7 @@ def text(self, (h, v), text):
582582
def setfont(self, fontkey):
583583
oldhandle = self.fonthandle
584584
GLFontCache.setfont(fontkey)
585-
if self.fonthandle <> oldhandle:
585+
if self.fonthandle != oldhandle:
586586
handle.setfont()
587587

588588

@@ -612,7 +612,7 @@ def redraw(self):
612612
import gl
613613
gl.winset(self.wid)
614614
width = gl.getsize()[1]
615-
if width <> self.width:
615+
if width != self.width:
616616
setdocsize = 1
617617
self.width = width
618618
for p in self.paralist:

Lib/lib-old/grep.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def showline(filename, lineno, line, prog):
7373
else:
7474
prefix = ' ' * len(prefix)
7575
for c in line:
76-
if c <> '\t': c = ' '
76+
if c != '\t': c = ' '
7777
prefix = prefix + c
7878
if start == end: prefix = prefix + '\\'
7979
else: prefix = prefix + '^'*(end-start)

Lib/lib-old/packmail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def pack(outfp, file, name):
2525
while 1:
2626
line = fp.readline()
2727
if not line: break
28-
if line[-1:] <> '\n':
28+
if line[-1:] != '\n':
2929
line = line + '\n'
3030
outfp.write('X' + line)
3131
outfp.write('!\n')

Lib/lib-old/tb.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def browser(tb):
2323
ptr = len(tblist)-1
2424
tb = tblist[ptr]
2525
while 1:
26-
if tb <> tblist[ptr]:
26+
if tb != tblist[ptr]:
2727
tb = tblist[ptr]
2828
print `ptr` + ':',
2929
printtbheader(tb)
@@ -76,11 +76,11 @@ def browserexec(tb, cmd):
7676
except:
7777
t, v = sys.exc_info()[:2]
7878
print '*** Exception:',
79-
if type(t) == type(''):
79+
if type(t) is type(''):
8080
print t,
8181
else:
8282
print t.__name__,
83-
if v <> None:
83+
if v is not None:
8484
print ':', v,
8585
print
8686
print 'Type help to get help.'
@@ -127,24 +127,24 @@ def printsymbols(d):
127127
print
128128

129129
def printobject(v, maxlevel):
130-
if v == None:
130+
if v is None:
131131
print 'None',
132132
elif type(v) in (type(0), type(0.0)):
133133
print v,
134-
elif type(v) == type(''):
134+
elif type(v) is type(''):
135135
if len(v) > 20:
136136
print `v[:17] + '...'`,
137137
else:
138138
print `v`,
139-
elif type(v) == type(()):
139+
elif type(v) is type(()):
140140
print '(',
141141
printlist(v, maxlevel)
142142
print ')',
143-
elif type(v) == type([]):
143+
elif type(v) is type([]):
144144
print '[',
145145
printlist(v, maxlevel)
146146
print ']',
147-
elif type(v) == type({}):
147+
elif type(v) is type({}):
148148
print '{',
149149
printdict(v, maxlevel)
150150
print '}',

0 commit comments

Comments
 (0)