MCPcopy
hub / github.com/pallets/flask / setdefault

Method setdefault

src/flask/ctx.py:92–102  ·  view source on GitHub ↗

Get the value of an attribute if it is present, otherwise set and return a default value. Like :meth:`dict.setdefault`. :param name: Name of attribute to get. :param default: Value to set and return if the attribute is not present. .. versionadded:: 0.11

(self, name: str, default: t.Any = None)

Source from the content-addressed store, hash-verified

90 return self.__dict__.pop(name, default)
91
92 def setdefault(self, name: str, default: t.Any = None) -> t.Any:
93 """Get the value of an attribute if it is present, otherwise
94 set and return a default value. Like :meth:`dict.setdefault`.
95
96 :param name: Name of attribute to get.
97 :param default: Value to set and return if the attribute is not
98 present.
99
100 .. versionadded:: 0.11
101 """
102 return self.__dict__.setdefault(name, default)
103
104 def __contains__(self, item: str) -> bool:
105 return item in self.__dict__

Callers 15

groupMethod · 0.80
__init__Method · 0.80
runMethod · 0.80
before_requestMethod · 0.80
after_requestMethod · 0.80
teardown_requestMethod · 0.80
add_url_ruleMethod · 0.80
before_app_requestMethod · 0.80
after_app_requestMethod · 0.80
teardown_app_requestMethod · 0.80
app_context_processorMethod · 0.80

Calls

no outgoing calls

Tested by 11

add_language_codeFunction · 0.64
app_before1Function · 0.64
app_before2Function · 0.64
parent_before1Function · 0.64
parent_before2Function · 0.64
child_before1Function · 0.64
child_before2Function · 0.64
setdefaultFunction · 0.64
add_language_codeFunction · 0.64
loadsMethod · 0.64