D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: fo
(self, other=(), /, **kwds)
| 962 | pass |
| 963 | |
| 964 | def update(self, other=(), /, **kwds): |
| 965 | ''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. |
| 966 | If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] |
| 967 | If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v |
| 968 | In either case, this is followed by: for k, v in F.items(): D[k] = v |
| 969 | ''' |
| 970 | if isinstance(other, Mapping): |
| 971 | for key in other: |
| 972 | self[key] = other[key] |
| 973 | elif hasattr(other, "keys"): |
| 974 | for key in other.keys(): |
| 975 | self[key] = other[key] |
| 976 | else: |
| 977 | for key, value in other: |
| 978 | self[key] = value |
| 979 | for key, value in kwds.items(): |
| 980 | self[key] = value |
| 981 | |
| 982 | def setdefault(self, key, default=None): |
| 983 | 'D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D' |