6 ms·
Python might have nice features, but it also has terrible features. Like using dicts for everything. It's not enough to allow good practices, you have to preven
by anthonygd 4y ago
Python might have nice features, but it also has terrible features. Like using dicts for everything. It's not enough to allow good practices, you have to prevent (or at least reduce) bad practices.
- gautamdivgi 4y agoYou can use dataclasses instead of dict now.
- ElectricalUnion 4y agoUnless you use __slots__, aren't all class-based objects [specifically python2 new style `class MyClass(object): pass` or all python3 classes] dicts in Python?
- gautamdivgi 4y agoI was talking about the dataclasses.dataclass annotation in 3.10/3.11. You can use slots with it. You’re right, they’re dicts unless slots are used. I read the parent comment and saying you can define types easily. But you can with dataclasses
- hbrn 4y agoCan you elaborate? What exactly is wrong with dicts?
- ActorNightly 4y ago>Like using dicts for everything Sorry what? This is absolutely not true.
- nephanth 4y agoI think they meant that the underlying representation for most stuff is a dict. Global variables are stored in a dict (`vars()`). Unless you use slots, an object is essentially a dict Doesn't really disturb me because they're not used like a dict in practice though