|
|
|
|
|
by tikhonj
1558 days ago
|
|
> Don't use classes for information. Use regular data structures (dict, list, tuple, set) and use functions to manipulate them. I've written a lot of functionalish Python, and I've found that this is a consistent way to breed code that's hard to understand. Instead, I would default to (usually frozen) dataclasses to represent data—they're functional records that also let your code reflect the concepts that make sense for whatever you're doing. A list of dictionaries of strings looks like any other list of dictionaries of strings; a sequence of User objects has clear semantics and, as a benefit, is harder to mutate in unexpected ways. |
|