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

List:       python-ideas
Subject:    [Python-ideas] Re: PEP 472 - regarding d[x=1, y=2] and similar
From:       Todd <toddrjen () gmail ! com>
Date:       2020-08-20 18:58:28
Message-ID: CAFpSVp+qAxyPypvFp6XNYP0=2zVD_mpAKUz5vZ03HFB6csTkbQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Thu, Aug 20, 2020 at 2:28 PM Jonathan Fine <jfine2358@gmail.com> wrote:

> Hi Todd
>
> You wrote:
>
> I think this is a bad idea, since it would mean classes could seem to
>> support keyword arguments but silently do the completely wrong thing,
>> especially if someone accidentally uses an older version.
>>
>
> I don't see this happening, and certainly don't see it as a new problem.
> To help me understand, please provide an example where this happens.
>
> It would be best to wait a few days first, after I've fixed
> https://github.com/jfine2358/python-kwkey/issues/2
>

As I said, it could very easily happen in xarray.   xarray has a structure
called a Dataset, which is a dict-style container for DataArrays (labelled
multidimensional arrays).  It supports both selecting an array by key or
indexing all the arrays by their indices.  So imagine a labelled array 'y'
with dimensions 'a' and 'b'.  So consider this example:

ds = Dataset({'y': y})
ds[a=1, b=2] = y[a=2, b=3]

If xarray supports keyword arguments, this would assign to the
corresponding values.  If it didn't, it would create a new element of the
Dataset containing "y[a=2, b=3]".  But "y" would continue working as it
would, only with different values than expected.

[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr">On Thu, Aug 20, 2020 at 2:28 PM Jonathan Fine &lt;<a \
href="mailto:jfine2358@gmail.com">jfine2358@gmail.com</a>&gt; wrote:<br></div><div \
class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi \
Todd</div><div><br></div><div>You wrote:</div><div><br></div><div \
class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div \
class="gmail_quote"><div>I think this is a bad idea, since it would mean classes \
could seem to support keyword arguments but silently do the completely wrong thing, \
especially if someone accidentally uses an older \
version.</div></div></div></blockquote><div><br></div><div>I don&#39;t see this \
happening, and certainly don&#39;t see it as a new problem. To help me understand, \
please provide an example where this happens.</div><div><br></div><div>It would be \
best to wait a few days first, after I&#39;ve fixed</div><div><a \
href="https://github.com/jfine2358/python-kwkey/issues/2" \
target="_blank">https://github.com/jfine2358/python-kwkey/issues/2</a></div></div></div></blockquote><div><br></div><div>As \
I said, it could very easily happen in xarray.     xarray has a structure called a \
Dataset, which is a dict-style container for DataArrays (labelled multidimensional \
arrays).   It supports both selecting an array by key or indexing all the arrays by \
their indices.   So imagine a labelled array &#39;y&#39; with dimensions &#39;a&#39; \
and &#39;b&#39;.   So consider this example:</div><div><br></div><div>ds = \
Dataset({&#39;y&#39;: y})</div><div>ds[a=1, b=2] = y[a=2, \
b=3]</div><div><br></div><div>If xarray supports keyword arguments, this would assign \
to the corresponding values.   If it didn&#39;t, it would create a new element of the \
Dataset containing &quot;y[a=2, b=3]&quot;.   But &quot;y&quot; would continue \
working as it would, only with different values than expected.    </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/3CLD2N424UUFF45LBRSUHZKRGW42MPL6/
 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