Message413054
Indeed, if you use Python keywords or other invalid Python names as keys of TypedDict, we must use the equivalent forms as follows:
```
Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'in': str}) # OK
Point2D = TypedDict('Point2D', x=int, y=int, in=str) # Error
```
Maybe we should add this to the docs.
And, it seems that adding examples for inheritance and attributes of TypedDict would make the docs clearer.
Would you mind if I submit a PR for those changes. :) |
|
Date |
User |
Action |
Args |
2022-02-11 09:42:36 | CharlieZhao | set | recipients:
+ CharlieZhao, docs@python, JelleZijlstra, sobolevn, AlexWaygood, 97littleleaf11 |
2022-02-11 09:42:36 | CharlieZhao | set | messageid: <1644572556.31.0.811251478029.issue46677@roundup.psfhosted.org> |
2022-02-11 09:42:36 | CharlieZhao | link | issue46677 messages |
2022-02-11 09:42:36 | CharlieZhao | create | |
|