3 ms·
When you are making str -> Any dictionaries it's quite likely you're better off with dataclasses or namedtuples anyway.
by guidopallemans 10mo ago
When you are making str -> Any dictionaries it's quite likely you're better off with dataclasses or namedtuples anyway.
- TheFlyingFish 10mo agoThat works if you're dealing with a known set of keys (i.e. what most statically-typed languages would call a struct). It falls down if you need something where the keys are unknowable until runtime, like a lookup table. I do like dataclasses, though. I find them sneaking into my code more and more as time goes on. Having a declared set of properties is really useful, and it doesn't hurt either that they're syntactically nicer to use.