MCPcopy
hub / github.com/pallets/werkzeug / setlistdefault

Method setlistdefault

src/werkzeug/datastructures/headers.py:449–466  ·  view source on GitHub ↗

Return the list of values for the key if it is in the headers, otherwise set the header to the list of values given by ``default`` and return that. Unlike :meth:`MultiDict.setlistdefault`, modifying the returned list will not affect the headers. :param key:

(self, key: str, default: cabc.Iterable[t.Any])

Source from the content-addressed store, hash-verified

447 return self._get_key(key)
448
449 def setlistdefault(self, key: str, default: cabc.Iterable[t.Any]) -> list[str]:
450 """Return the list of values for the key if it is in the
451 headers, otherwise set the header to the list of values given
452 by ``default`` and return that.
453
454 Unlike :meth:`MultiDict.setlistdefault`, modifying the returned
455 list will not affect the headers.
456
457 :param key: The header key to get.
458 :param default: An iterable of values to set for the key if it
459 is not in the headers.
460
461 .. versionadded:: 1.0
462 """
463 if key not in self:
464 self.setlist(key, default)
465
466 return self.getlist(key)
467
468 @t.overload
469 def __setitem__(self, key: str, value: t.Any) -> None: ...

Calls 2

setlistMethod · 0.95
getlistMethod · 0.95