[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-ideas
Subject:    [Python-ideas] Re: PEP 472 - new dunder attribute, to influence item access
From:       Todd <toddrjen () gmail ! com>
Date:       2020-08-28 12:07:12
Message-ID: CAFpSVpJqr1tHY2WdmPY6HG7oxJJ7F8-nO90_ugAwYY_a=ntzuQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Thu, Aug 27, 2020, 19:30 Joseph Martinot-Lagarde <contrebasse@gmail.com>
wrote:

> As for foo[a=1, b=2], I'd propose to keep it a SyntaxError for now, and
> always require an index. This way it can be changed later when people are
> more used to the keyword args and have more ideas of what would be good as
> a default argument. In the face of ambiguity, refuse the temptation to
> guess ;)
>

This really wouldn't work for xarray, either.

I think the simplest default value would be Ellipsis.  So foo[a=1, b=2]
would be equivalent to foo[..., a=1, b=2]

But I don't see why this is a problem we have to deal with.  The index
argument can just not be passed at all, and it is up to the class developer
to pick an appropriate sentinel if needed.

>

[Attachment #5 (text/html)]

<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On \
Thu, Aug 27, 2020, 19:30 Joseph Martinot-Lagarde &lt;<a \
href="mailto:contrebasse@gmail.com">contrebasse@gmail.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">As for foo[a=1, b=2], I&#39;d \
propose to keep it a SyntaxError for now, and always require an index. This way it \
can be changed later when people are more used to the keyword args and have more \
ideas of what would be good as a default argument. In the face of ambiguity, refuse \
the temptation to guess ;)<br></blockquote></div></div><div dir="auto"><br></div><div \
dir="auto">This really wouldn&#39;t work for xarray, either.</div><div \
dir="auto"><br></div><div dir="auto">I think the simplest default value would be \
Ellipsis.   So foo[a=1, b=2] would be equivalent to foo[..., a=1, b=2]<span \
style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:&quot;lucida \
grande&quot;,arial,sans-serif;font-size:16px"></span></div><div \
dir="auto"><br></div><div dir="auto">But I don&#39;t see why this is a problem we \
have to deal with.   The index argument can just not be passed at all, and it is up \
to the class developer to pick an appropriate sentinel if needed.</div><div \
dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 \
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> </blockquote></div></div></div>



_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@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/UDMJ6A2DGU7VNEAEPQQO5HYFVVQ4EN7F/
 Code of Conduct: http://python.org/psf/codeofconduct/



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic