Update tree with key-value pairs from other mapping or iterable.
(self, other)
| 83 | return default |
| 84 | |
| 85 | def update(self, other): |
| 86 | """Update tree with key-value pairs from other mapping or iterable.""" |
| 87 | if hasattr(other, "items"): |
| 88 | # other is a mapping (dict-like) |
| 89 | for key, value in other.items(): |
| 90 | self[key] = value |
| 91 | elif hasattr(other, "keys"): |
| 92 | # other has keys method but no items (like dict.keys()) |
| 93 | for key in other.keys(): |
| 94 | self[key] = other[key] |
| 95 | else: |
| 96 | # other is an iterable of (key, value) pairs |
| 97 | for key, value in other: |
| 98 | self[key] = value |
| 99 | |
| 100 | def copy(self): |
| 101 | """Create a shallow copy of the tree.""" |