5 ms·
Immutability is nice though.
by johtso 5y ago
Immutability is nice though.
- wyldfire 5y agoAlso it's nice for bad references to trigger AttributeError which is almost always a design error, whereas KeyError is not always so. I haven't tried it but type hints are probably smart enough to find errors like this statically with namedtuple, but probably not so with a dict.
- gjulianm 5y agoI think you need to use typing.NamedTuple to get typing support. On the other hand, you can use TypedDict [1] to get type hints on dictionaries. 1: https://www.python.org/dev/peps/pep-0589/ https://www.python.org/dev/peps/pep-0589/
- deleted 5y ago[deleted]