diff options
author | Raymond Hettinger <python@rcn.com> | 2002-06-01 14:18:47 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2002-06-01 14:18:47 (GMT) |
commit | 54f0222547b1e92cd018ef132307a6f793dc9505 (patch) | |
tree | 667480d89feb3f9c7ca44e4ffa7bf39e725c120d /Lib/rfc822.py | |
parent | 9d5e4aa4149edb92f6d28c9390d776ae4a1d719a (diff) | |
download | cpython-54f0222547b1e92cd018ef132307a6f793dc9505.zip cpython-54f0222547b1e92cd018ef132307a6f793dc9505.tar.gz cpython-54f0222547b1e92cd018ef132307a6f793dc9505.tar.bz2 |
SF 563203. Replaced 'has_key()' with 'in'.
Diffstat (limited to 'Lib/rfc822.py')
-rw-r--r-- | Lib/rfc822.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/rfc822.py b/Lib/rfc822.py index 0ce546c..6495f5f 100644 --- a/Lib/rfc822.py +++ b/Lib/rfc822.py @@ -406,7 +406,7 @@ class Message: def __delitem__(self, name): """Delete all occurrences of a specific header, if it is present.""" name = name.lower() - if not self.dict.has_key(name): + if not name in self.dict: return del self.dict[name] name = name + ':' @@ -427,14 +427,14 @@ class Message: def get(self, name, default=""): name = name.lower() - if self.dict.has_key(name): + if name in self.dict: return self.dict[name] else: return default def setdefault(self, name, default=""): lowername = name.lower() - if self.dict.has_key(lowername): + if lowername in self.dict: return self.dict[lowername] else: text = name + ": " + default @@ -446,7 +446,11 @@ class Message: def has_key(self, name): """Determine whether a message contains the named header.""" - return self.dict.has_key(name.lower()) + return name.lower() in self.dict + + def __contains__(self, name): + """Determine whether a message contains the named header.""" + return name.lower() in self.dict def keys(self): """Get all of a message's header field names.""" @@ -919,7 +923,7 @@ def parsedate_tz(data): return None tzoffset = None tz = tz.upper() - if _timezones.has_key(tz): + if tz in _timezones: tzoffset = _timezones[tz] else: try: @@ -1010,8 +1014,8 @@ if __name__ == '__main__': print 'Lines:', n print '-'*70 print 'len =', len(m) - if m.has_key('Date'): print 'Date =', m['Date'] - if m.has_key('X-Nonsense'): pass + if 'Date' in m: print 'Date =', m['Date'] + if 'X-Nonsense' in m: pass print 'keys =', m.keys() print 'values =', m.values() print 'items =', m.items() |