+ 6
get(key[, default])
Return the value for key if key is in the dictionary, else default. If default is not given, it defaults to None, so that this method never raises a KeyError.ex:-
dictionary = {"Name": "Harry", "Age": 17} dictionary["Name"] dictionary.get("Name")
It allows you to provide a default value if the key is missing:
dictionary.get("bogus", default_value)
returns default_value (whatever you choose it to be), whereas
dictionary["bogus"]
would raise a KeyError.
If omitted, default_value is None, such that
dictionary.get("bogus") # <-- No default specified -- defaults to None
returns None just like
dictionary.get("bogus", None)
would.
https://stackoverflow.com/questions/2068349/understanding-get-method-in-JUMP_LINK__&&__python__&&__JUMP_LINK