On Fri, 10 Jul 2020 at 15:23, Jonathan Fine <jfine2...@gmail.com> wrote:
> With hindsight, I can see your difficulty. The original idea is to extend the 
> syntax so that
>     >>> m = MyMap()
>     >>> m[1, 2, 3, a=4, b=5] = 'foobar'
> is allowed in some future version of Python.
>
> Python's syntax already allows:
>     >>> m = MyMap()
>     >>> m[K(1, 2, 3, a=4, b=5)] = 'foobar'
>
> My idea is to implement this, so that we can better explore the original 
> idea. (In particular, this would allow the idea to be tested in practice, and 
> perhaps acquire a community of users.)
[...]
> The code I wrote, which wasn't clear enough, sketched an adapter between two 
> points of view (although for get rather than set).

OK, thanks. I'm probably not the target for your comment in that case,
as (now that you've clarified) the approach you suggest seems
straightforward enough to me, but (as I said) looks more at
implementation than design. I get what you're saying, that this
approach would allow people to try out the idea in current Python,
with minimally-intrusive extra syntax needed. So maybe it'll encourage
people to try the idea out for their use cases.

On Fri, 10 Jul 2020 at 15:32, Ricky Teachey <ri...@teachey.org> wrote:
>  This is confusing to me because `my_mapping[1,2,3]` is already valid syntax 
> equivalent to `my_mapping.__setitem__(my_mapping, (1,2,3))`. Wouldn't a 
> change to translate the tuple into this K object lead to big problems for a 
> lot of existing code...?

This is much more the sort of question I think we should be exploring
at this stage. You can't change how currently-valid syntax is
interpreted, so you get a big change of behaviour between d[1,2] and
d[1, 2, k=3]. This is where a real-world use case is essential, to try
to explore whether that behaviour change is minor, or a showstopper.
There's no way to tell with made up examples. Thanks, Ricky, for
pointing this out explicitly.

Paul
_______________________________________________
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/D5AW3KUPMZ2ZLAQODTCN3YOSXDZ3F3NG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to