Re:The Python Paradox
by AdamN on Friday January 27, 2023 @08:17AM
(#34545597)
That's sort of outdated. Python now has type hints, protocol oriented programming support, and is quite fast (for what it is). This wasn't the case back in the day but it's all there now.
[ Parent
| on HN ]
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.
Re:The Python Paradox
by gautamdivgi on Friday January 27, 2023 @09:48AM
(#34546625)
You can use dataclasses instead of dict now.
Re:The Python Paradox
by ElectricalUnion on Friday January 27, 2023 @10:17AM
(#34546954)
Unless you use __slots__, aren't all class-based objects [specifically python2 new style `class MyClass(object): pass` or all python3 classes] dicts in Python?
Re:The Python Paradox
by gautamdivgi on Friday January 27, 2023 @10:34AM
(#34547141)
I 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
Can you elaborate? What exactly is wrong with dicts?
Re:The Python Paradox
by ActorNightly on Friday January 27, 2023 @12:32PM
(#34548965)
>Like using dicts for everything
Sorry what? This is absolutely not true.
I 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