Skip to content

Commit 6e3dbbd

Browse files
committed
replace has_key with 'in' operator
1 parent de05599 commit 6e3dbbd

29 files changed

Lines changed: 71 additions & 71 deletions

Lib/bdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def clear_break(self, filename, lineno):
257257
# pair, then remove the breaks entry
258258
for bp in Breakpoint.bplist[filename, lineno][:]:
259259
bp.deleteMe()
260-
if not Breakpoint.bplist.has_key((filename, lineno)):
260+
if (filename, lineno) not in Breakpoint.bplist:
261261
self.breaks[filename].remove(lineno)
262262
if not self.breaks[filename]:
263263
del self.breaks[filename]
@@ -464,7 +464,7 @@ def __init__(self, file, line, temporary=0, cond=None, funcname=None):
464464
Breakpoint.next = Breakpoint.next + 1
465465
# Build the two lists
466466
self.bpbynumber.append(self)
467-
if self.bplist.has_key((file, line)):
467+
if (file, line) in self.bplist:
468468
self.bplist[file, line].append(self)
469469
else:
470470
self.bplist[file, line] = [self]

Lib/curses/has_key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def has_key(ch):
182182
L = []
183183
_curses.initscr()
184184
for key in _capability_names.keys():
185-
system = _curses.has_key(key)
185+
system = key in _curses
186186
python = has_key(key)
187187
if system != python:
188188
L.append( 'Mismatch for key %s, system=%i, Python=%i'

Lib/email/message.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,16 +249,16 @@ def set_charset(self, charset):
249249
# BAW: should we accept strings that can serve as arguments to the
250250
# Charset constructor?
251251
self._charset = charset
252-
if not self.has_key('MIME-Version'):
252+
if 'MIME-Version' not in self:
253253
self.add_header('MIME-Version', '1.0')
254-
if not self.has_key('Content-Type'):
254+
if 'Content-Type' not in self:
255255
self.add_header('Content-Type', 'text/plain',
256256
charset=charset.get_output_charset())
257257
else:
258258
self.set_param('charset', charset.get_output_charset())
259259
if str(charset) != charset.get_output_charset():
260260
self._payload = charset.body_encode(self._payload)
261-
if not self.has_key('Content-Transfer-Encoding'):
261+
if 'Content-Transfer-Encoding' not in self:
262262
cte = charset.get_body_encoding()
263263
try:
264264
cte(self)
@@ -551,7 +551,7 @@ def get_param(self, param, failobj=None, header='content-type',
551551
VALUE item in the 3-tuple) is always unquoted, unless unquote is set
552552
to False.
553553
"""
554-
if not self.has_key(header):
554+
if header not in self:
555555
return failobj
556556
for k, v in self._get_params_preserve(failobj, header):
557557
if k.lower() == param.lower():
@@ -582,7 +582,7 @@ def set_param(self, param, value, header='Content-Type', requote=True,
582582
if not isinstance(value, tuple) and charset:
583583
value = (charset, language, value)
584584

585-
if not self.has_key(header) and header.lower() == 'content-type':
585+
if header not in self and header.lower() == 'content-type':
586586
ctype = 'text/plain'
587587
else:
588588
ctype = self.get(header)
@@ -617,7 +617,7 @@ def del_param(self, param, header='content-type', requote=True):
617617
False. Optional header specifies an alternative to the Content-Type
618618
header.
619619
"""
620-
if not self.has_key(header):
620+
if header not in self:
621621
return
622622
new_ctype = ''
623623
for p, v in self.get_params(header=header, unquote=requote):
@@ -653,7 +653,7 @@ def set_type(self, type, header='Content-Type', requote=True):
653653
if header.lower() == 'content-type':
654654
del self['mime-version']
655655
self['MIME-Version'] = '1.0'
656-
if not self.has_key(header):
656+
if header not in self:
657657
self[header] = type
658658
return
659659
params = self.get_params(header=header, unquote=requote)

Lib/encodings/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def search_function(encoding):
147147
pass
148148
else:
149149
for alias in codecaliases:
150-
if not _aliases.has_key(alias):
150+
if alias not in _aliases:
151151
_aliases[alias] = modname
152152

153153
# Return the registry entry

Lib/hotshot/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, logfn):
3030
self._reader = _hotshot.logreader(logfn)
3131
self._nextitem = self._reader.next
3232
self._info = self._reader.info
33-
if self._info.has_key('current-directory'):
33+
if 'current-directory' in self._info:
3434
self.cwd = self._info['current-directory']
3535
else:
3636
self.cwd = None

Lib/idlelib/EditorWindow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,8 @@ def ApplyKeybindings(self):
705705
if accel:
706706
itemName = menu.entrycget(index, 'label')
707707
event = ''
708-
if menuEventDict.has_key(menubarItem):
709-
if menuEventDict[menubarItem].has_key(itemName):
708+
if menubarItem in menuEventDict:
709+
if itemName in menuEventDict[menubarItem]:
710710
event = menuEventDict[menubarItem][itemName]
711711
if event:
712712
accel = get_accelerator(keydefs, event)

Lib/idlelib/FileList.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def open(self, filename, action=None):
2525
master=self.root)
2626
return None
2727
key = os.path.normcase(filename)
28-
if self.dict.has_key(key):
28+
if key in self.dict:
2929
edit = self.dict[key]
3030
edit.top.wakeup()
3131
return edit
@@ -79,7 +79,7 @@ def filename_changed_edit(self, edit):
7979
newkey = os.path.normcase(filename)
8080
if newkey == key:
8181
return
82-
if self.dict.has_key(newkey):
82+
if newkey in self.dict:
8383
conflict = self.dict[newkey]
8484
self.inversedict[conflict] = None
8585
tkMessageBox.showerror(

Lib/idlelib/MultiCall.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def __init__(self, type, widget, widgetinst):
185185
seq, handler)))
186186

187187
def bind(self, triplet, func):
188-
if not self.bindedfuncs.has_key(triplet[2]):
188+
if triplet[2] not in self.bindedfuncs:
189189
self.bindedfuncs[triplet[2]] = [[] for s in _states]
190190
for s in _states:
191191
lists = [ self.bindedfuncs[detail][i]

Lib/idlelib/MultiStatusBar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(self, master=None, **kw):
99
self.labels = {}
1010

1111
def set_label(self, name, text='', side=LEFT):
12-
if not self.labels.has_key(name):
12+
if name not in self.labels:
1313
label = Label(self, bd=1, relief=SUNKEN, anchor=W)
1414
label.pack(side=side)
1515
self.labels[name] = label

Lib/idlelib/ObjectBrowser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def keys(self):
126126

127127
def make_objecttreeitem(labeltext, object, setfunction=None):
128128
t = type(object)
129-
if dispatch.has_key(t):
129+
if t in dispatch:
130130
c = dispatch[t]
131131
else:
132132
c = ObjectTreeItem

0 commit comments

Comments
 (0)