> For the complete documentation index, see [llms.txt](https://huang-jason.gitbook.io/python/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://huang-jason.gitbook.io/python/dict.md).

# \_\_dict\_\_

```python
class Target(object):

    def __init__(self):
        self.a = 1
        self.b = 2


t = Target()
t.__dict__
# {'a': 1, 'b': 2}
```

reassigning leads to ***replacement***.

```python
t.__dict__ = { 'a': 3 }
t.__dict__
# {'a': 3}

t.b
# AttributeError: 'Target' object has no attribute 'b'
```

***update*** changes some items only.

```python
t.__dict__ = { 'a': 1, 'b': 2 }
t.__dict__
# {'a': 1, 'b': 2}

t.__dict__.update({'a':10, 'd': 11})
# {'a': 10, 'b': 2, 'd': 11}
t.__dict__
t.b
# 2
```
