On Wed, Aug 5, 2020, 10:38 <2qdxy4rzwzuui...@potatochowder.com> wrote:

> On 2020-08-04 at 10:58:51 -0400,
> Todd <toddr...@gmail.com> wrote:
>
> > My main issue with this is that, in my opinion, dunders are not
> > something a beginner should be messing with anyway.  By the time
> > someone is experienced enough to start working on this, they are also
> > experienced enough to understand that special cases like this exist
> > for historical reasons.
>
> Ouch.
>
> Who am I to tell beginners what they should and shouldn't be messing
> with, and in what order?  IMNSHO, history (let alone understanding it)
> comes *way* after writing a few dunders, even if you don't count
> __init__ as a dunder.
>

I should have been more clear, I was talking about these specific dunder
methods.  Overriding indexing isn't something that people will typically
deal with before understanding the sequences indexing acts on, which is all
they really need to understand to make sense of the current API.

And history is hard to avoid.  Why is it "def" instead of "function"?  Why
do dunder methods use "__" at all?  Why does indexing use 0 instead of 1?
Some things they are just going to need to accept are the way they are, and
these are all things people are almost certainly going to need to encounter
before making their own classes.

Special cases aren't special enough to break the rules.
>

But they're aren't really any rules being broken here.  It may be a
sub-optimal solution in this case, but not a forbidden or even uncommon
approach.

>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/UJVXA5RF4ZBFS43XEOA6B3ECQ3B3F53X/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to