<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 25, 2017 at 7:49 PM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On 2017-07-25 02:57, Nick Coghlan wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
On 25 July 2017 at 02:46, Michel Desmoulin <<a href="mailto:desmoulinmichel@gmail.com" target="_blank">desmoulinmichel@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Le 24/07/2017 à 16:12, Nick Coghlan a écrit :<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
On 22 July 2017 at 01:18, Guido van Rossum <<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Honestly I would like to declare the bare (x=1, y=0) proposal dead. Let's<br>
encourage the use of objects rather than tuples (named or otherwise) for<br>
most data exchanges. I know of a large codebase that uses dicts instead of<br>
objects, and it's a mess. I expect the bare ntuple to encourage the same<br>
chaos.<br>
</blockquote></blockquote>
<br>
This is the people working on big code base talking.<br>
</blockquote>
<br>
Dedicated syntax:<br>
<br>
     (x=1, y=0)<br>
<br>
New builtin:<br>
<br>
     ntuple(x=1, y=0)<br>
<br>
So the only thing being ruled out is the dedicated syntax option,<br>
since it doesn't let us do anything that a new builtin can't do, it's<br>
harder to find help on (as compared to "help(ntuple)" or searching<br>
online for "python ntuple"), and it can't be readily backported to<br>
Python 3.6 as part of a third party library (you can't easily backport<br>
it any further than that regardless, since you'd be missing the<br>
order-preservation guarantee for the keyword arguments passed to the<br>
builtin).<br>
<br>
</blockquote></span>
[snip]<br>
<br>
I think it's a little like function arguments.<br>
<br>
Arguments can be all positional, but you have to decide in what order they are listed. Named arguments are clearer than positional arguments when calling functions.<br>
<br>
So an ntuple would be like a tuple, but with names (attributes) instead of positions.<br>
<br>
I don't see how they could be compatible with tuples because the positions aren't fixed. You would need a NamedTuple where the type specifies the order.<br>
<br>
I think...<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br>
</div></div></blockquote></div><br>Most likely ntuple() will require keyword args only, whereas for collections.namedtuple they are mandatory only during declaration. The order is the same as kwargs, so: </div><div class="gmail_extra"><br></div><div class="gmail_extra">>>> nt = ntuple(x=1, y=2)</div><div class="gmail_extra"><div>>>> nt[0]</div><div>1</div><div>>>> nt[1]</div><div>2</div><div><br></div><div>What's less clear is how isinstance() should behave. Perhaps:</div><div><br></div><div>>>> t = (1, 2)</div><div>>>> nt = ntuple(x=1, y=2)</div><div>>>> isinstance(nt, tuple)</div><div>True</div><div><div><div>>>> isinstance(t, ntuple)</div></div></div><div>False</div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Giampaolo - <a href="http://grodola.blogspot.com" target="_blank">http://grodola.blogspot.com</a></div><div><br></div><div><br></div></div></div>
</div></div>