get
method detected PTC-W0031params.get('fields')
806 ))
807
808 logger.debug("Configuring Chickadee")
809 fields = params.get('fields').split(',') if len(params.get('fields', [])) else None810 chickadee = Chickadee(fields=fields)
811 chickadee.resolver = params.get('resolver', 'ip_api')
812 chickadee.resolve_ips = not params.get('no-resolve')
Use of a method on the return value of a dictionary's get
method without checking if the value exists may give an AttributeError
during runtime.
By default, the get
method returns None
if the key is not found in the dictionary.
It is recommended to either provide a default
value to be returned by get
when key doesn't exist, or check that the default value is not None
before using any other method on it.
def generate_username(name):
return student_record.get(name).lower()
def generate_username(name):
official_name = student_record.get(name)
return official_name.lower() if official_name else None