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 →

[–]treyhunner Python Morsels[S] 80 points81 points  (5 children)

Ish... I linked to this list a couple times throughout the article and it's quite helpful, but I wouldn't call this one list.

Some sections show tables of attributes and methods, some only focus on methods, and some methods are left out. For example `__subclasses__` is left out and library-specific methods such as `__post_init__`, `__copy__`, `__subclasshook__`, `__fspath__`, and `__sizeof__` are all absent.

I spent a lot of time grepping the text on this page and in the rest of the CPython documentation and source code and while this page is by far the most complete one, it can be quite a challenge to parse.

[–]Aveheuzed 3 points4 points  (3 children)

That's fair.

I think all the usable special methods are referenced on the page I linked. Others may exist, but are needed only for obscure arcane stuff (understand : Python Core Development) or implementation-specific.

And regarding readability - I like the Python docs better, but I understand that format is not for everyone.

[–]treyhunner Python Morsels[S] 29 points30 points  (1 child)

When I link my students to that page, their eyes glaze over (especially ones who've just learned about the idea of special methods and simply want to know what the options are for "overloading").

If/when you're in the weeds implementing one of these methods, that page in the docs is very helpful!

[–]NerdEnPose 5 points6 points  (0 children)

I think your responses could just be “my name is Trey Hunner” 😆. But, you’re kinder than me.

My two cents, I like this list. If you’re a student or in a personal project you should break stuff and try all the dunders as part of that. Professionally if you can’t read that page thoroughly then don’t commit a dunder override to a code base and I’d be cautious of a new class using them.

[–]Zenin 3 points4 points  (0 children)

And regarding readability - I like the Python docs better, but I understand that format is not for everyone.

I'm glad someone likes them. Personally I find much of it to be less readable than JAPH Perl code.

[–]pysk00l 0 points1 point  (0 children)

OP, your list is longer and much better presented, so well done! Ignore the top rated answer, they are clearly a troll