MCPcopy
hub / github.com/fluentpython/example-code-2e / update

Method update

21-async/mojifinder/bottle.py:2135–2144  ·  view source on GitHub ↗

If the first parameter is a string, all keys are prefixed with this namespace. Apart from that it works just as the usual dict.update(). Example: ``update('some.namespace', key='value')``

(self, *a, **ka)

Source from the content-addressed store, hash-verified

2133 return self
2134
2135 def update(self, *a, **ka):
2136 ''' If the first parameter is a string, all keys are prefixed with this
2137 namespace. Apart from that it works just as the usual dict.update().
2138 Example: ``update('some.namespace', key='value')`` '''
2139 prefix = ''
2140 if a and isinstance(a[0], basestring):
2141 prefix = a[0].strip('.') + '.'
2142 a = a[1:]
2143 for key, value in dict(*a, **ka).items():
2144 self[prefix+key] = value
2145
2146 def setdefault(self, key, value):
2147 if key not in self:

Callers 15

__init__Method · 0.95
__call__Method · 0.95
__init__Function · 0.45
__init__Function · 0.45
expand_cc_argsFunction · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 1

itemsMethod · 0.45

Tested by

no test coverage detected