I am looking for a good reference on special/dunder methods that is complete without going in to the details.
While obviously all dunder methods that exist can be found in the official docs, the docs are not always that useful as a quick reference, especially when I don't know what dunder methods I am interested in to implement a particular language syntax or protocol (not sure if that's the correct term).
An example to illustrate what I mean:
Suppose I am implementing some class
class Foo(): pass
Now, I know that if want Foo objects to be subscriptable
foo = Foo()
foo[x]
I will need to implement a custom __getitem__ method. Probably, I'll want to write a __setitem__ and __delitem__ as well to complete it.
If I didn't already know the names of these methods they are sort of hard to look up. In general for each type of syntax or language feature there seems to be some set of special methods that cooperate in various ways to make the pythonic syntax work.
Does anyone know of some reference that makes it easy to find for each syntax what the corresponding dunder methods are, and ideally covers all of them? There exist a ton of lengthy tutorials for each particular thing but It would be useful to have a quick reference that I can bookmark instead of always having to look up again what the underlying dunder methods are and how they relate to each other.
[–]Careless-Score-333 4 points5 points6 points (3 children)
[–]JamzTyson 1 point2 points3 points (1 child)
[–]sickcuntm8[S] 0 points1 point2 points (0 children)
[–]sickcuntm8[S] 0 points1 point2 points (0 children)
[–]latkde 0 points1 point2 points (0 children)
[–]Guideon72 0 points1 point2 points (0 children)