On Wed, Aug 26, 2020 at 4:01 PM Christopher Barker <python...@gmail.com>
wrote:

> Yes, it's slightly funny that square brackets convert to `index` rather
>> than `*index`, but that ship sailed very long ago, and it's no big deal.
>> There's no problem that needs solving and no need for code churn.
>>
> TL;DR -- let's watch the strong language here -- these proposals do
> attempt to address a real problem -- probably not worth the downsides, but
> this "doesn't solve any problem", "no one asked for it", etc, is really
> dismissive.
>

I have read hundreds of comments in this thread.  As I stated, I have yet
to see *anyone* identify a "problem that needs solving" with all the
convoluted new objects and weird support methods.  There is absolutely
nothing whatsoever that cannot be easily done with the obvious and
straightforward signature:

    .__getitem__(self, index, **kws)

Not one person has even vaguely suggested a single use case that cannot be
addressed that way, nor even a single case where a different approach would
even be slightly easier to work with.

... there was an odd response that a custom class might want to specify its
special keywords.  Which of course they can1  I was just giving the
shorthand version.  Some particular class can allow and define whichever
keywords it wants, just like with every other function or method.

---

Yes, the parser will have to do something special with the stuff in square
brackets.  As it has always done something special for stuff in square
brackets.  Obviously, if we call:

    mything[1, 2:3, four=4, five=5]

That needs to get translated, at the bytecode level, into the equivalent of:

    mything.__getitem__((1, slice(2,3)), four=4, five=5)

But the class MyThing is free to handle its keyword arguments `four` and
`five` how it likes.  They might have defaults or not (i.e. **kws).  I
think dict and list should, for now, raise an exception if they see any
**kws (but ignoring them is not completely absurd either).

The only question that seems slightly reasonable to see as open is "What is
`index` if only keywords are subscripted?"  Some sort of sentinel is
needed, but conceivably None or an empty tuple wouldn't be backward
compatible since those *can* be subscripts legally now.

-- 
The dead increasingly dominate and strangle both the living and the
not-yet born.  Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.
_______________________________________________
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/K4BRZIV6KIQIHLMU2SV765XGG73OGA3H/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to