if "username" in some_dict: ...
-----
some_dict.get("username", "default")
try: u = some_dict["username"] except KeyError: # long error case code if needed