Open willp opened 8 years ago
I'm inclined to agree with you on __index__
(based on my reading of https://docs.python.org/2.5/whatsnew/pep-357.html). For __bool__
and __dir__
I understand why you would think so -- and I might even agree, especially if constrained by the existing categories. The categories are taken verbatim from http://www.rafekettler.com/magicmethods.html, and I think the typeconv category is fundamentally flawed in a language where variables don't have type (the object has type, but you're not converting the object type..). E.g. __oct__
is not a conversion to an "octal" type, since it returns a string. Similarly for representation
, there is a fundamental difference between methods such as __repr__
/ __hash__
/ __sizeof__
and __str__
/ __unicode__
/ __nonzero__
(__bool__
)...
just my opinion, but i think the categorizations of dunder methods could be improved slightly:
__bool__
is more of atypeconv
than arepresentation
__dir__
is more of areflection
than arepresentation
__index__
is more of acontainer
than atypeconv
again, just my opinion.