2 ms·
I'm not sure I agree with "don't write classes". This is Python: classes are the state container. That's the structure Python provides for grouping related pi
by jrockway 14y ago
I'm not sure I agree with "don't write classes". This is Python: classes are the state container. That's the structure Python provides for grouping related pieces of information together, and that's the structure all other Python libraries and programmers expect you to use.
Now if you don't want to type the code every time, that's fine: use collections.namedtuple.
- andreasvc 14y agoA class without methods is just syntactic sugar wrapping around a dictionary of attributes, so in that sense it could be simpler to use the dictionary directly.
- jrockway 14y agoThe example from the slides was a __str__ method for a data structure, which makes a class the perfect fit in Python. (They did not call it __str__, of course.)