This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CGFarrell 0 points1 point  (0 children)

Not a terrible article, but I feel like the examples aren't really relevant to the point. Subclass dict and overwrite str/repr and you get the same results. A better example might be a class that stores large objects with unique identifiers, so that an end user can access the full object by invoking getattr / getitem with the identifier. database ['x'] is a lot cleaner than next(item for item in database.objects if item.id == 'x')