mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Replace key existence tests with dict.get()
Replaced instances of this pattern:
if 'key' in somedict:
var = somedict['key']
else:
var = ""
...with this much simpler pattern:
var = somedict.get('key', "")
Some variations, like returning None if the key is not found were also
replaced.
This commit is contained in:
@@ -179,10 +179,7 @@ class XMLNode:
|
||||
def get_attr(self, attr):
|
||||
"""
|
||||
"""
|
||||
if attr in self.__attrs:
|
||||
return self.__attrs[attr]
|
||||
|
||||
return None
|
||||
return self.__attrs.get(attr)
|
||||
|
||||
def get_attrs(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user