Re: display of dicts?
Steve Holden <[email protected]> Tue, 19 Dec 2017 17:50:28 +0000
| Newsgroups | gmane.comp.python.ipython.devel |
|---|---|
| Message-ID | <CAMofdRAxKn5vWQeGifUvdHd=vRQQwHKVxe_1TGTm21Cr=c0Vig@mail.gmail.com> |
--===============5321314140487418340== Content-Type: multipart/alternative; boundary="94eb2c123586425aeb0560b51ac5" --94eb2c123586425aeb0560b51ac5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Dec 19, 2017 at 5:37 PM, Thomas Kluyver <[email protected]> wrote: > On 19 December 2017 at 17:24, Chris Barker <[email protected]> wrote: > >> Granted, string keys where alphabetization makes sense are pretty darn >> common, but still a "special case" >> > > I'd argue that they're common enough to be the typical case, though > perhaps my definition of 'makes sense' is a bit broader than yours. And > sorting can also make sense for numeric keys. > > >> In fact, I discovered this with this example, which I used in my intro t= o >> Python class to demonstrate dict's arbitrary order >> > > I think this is exactly the tension we're facing. People teaching intro t= o > Python courses want to show what a dictionary *is*, and you don't want > IPython's features to obscure that. But other than learning about > dictionaries, I suspect that sorted order is useful more often than > insertion order. > > I'm leaning slightly towards making insertion order the default in Python > 3.7 - it will be meaningful some of the time, and it is now part of what = a > dict is - but I think we should ensure the same release adds an easy way = to > switch back to displaying sorted dicts. > =E2=80=8BWhat about adding a "sorted" method to dicts that produces a dict = with the same keys but the keys inserted =E2=80=8Bin sorted order? regards Steve --94eb2c123586425aeb0560b51ac5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-size:small">On = Tue, Dec 19, 2017 at 5:37 PM, Thomas Kluyver <span dir=3D"ltr"><<a href= =3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>></sp= an> wrote:<br></div><div class=3D"gmail_extra"><div class=3D"gmail_quote"><= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><= div class=3D"gmail_quote"><span class=3D"">On 19 December 2017 at 17:24, Ch= ris Barker <span dir=3D"ltr"><<a href=3D"mailto:[email protected]" t= arget=3D"_blank">[email protected]</a>></span> wrote:<br><blockquote= class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli= d;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><div class= =3D"gmail_quote"><div>Granted, string keys where alphabetization makes sens= e are pretty darn common, but still a "special case"</div></div><= /div></div></blockquote><div><br></div></span><div>I'd argue that they&= #39;re common enough to be the typical case, though perhaps my definition o= f 'makes sense' is a bit broader than yours. And sorting can also m= ake sense for numeric keys.<br></div><span class=3D""><div>=C2=A0</div><blo= ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c= cc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><div= class=3D"gmail_quote"><div></div><div>In fact, I discovered this with this= example, which I used in my intro to Python class to demonstrate dict'= s arbitrary order</div></div></div></div></blockquote><div><br></div></span= ><div>I think this is exactly the tension we're facing. People teaching= intro to Python courses want to show what a dictionary *is*, and you don&#= 39;t want IPython's features to obscure that. But other than learning a= bout dictionaries, I suspect that sorted order is useful more often than in= sertion order.</div><div><br></div><div>I'm leaning slightly towards ma= king insertion order the default in Python 3.7 - it will be meaningful some= of the time, and it is now part of what a dict is - but I think we should = ensure the same release adds an easy way to switch back to displaying sorte= d dicts.</div></div></div></div></blockquote><div><br></div><div class=3D"g= mail_default" style=3D"font-size:small">=E2=80=8BWhat about adding a "= sorted" method to dicts that produces a dict with the same keys but th= e keys inserted =E2=80=8Bin sorted order?</div><div class=3D"gmail_default"= style=3D"font-size:small"><br></div><div class=3D"gmail_default" style=3D"= font-size:small">regards</div><div class=3D"gmail_default" style=3D"font-si= ze:small">=C2=A0Steve</div></div></div></div> --94eb2c123586425aeb0560b51ac5-- --===============5321314140487418340== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ IPython-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/ipython-dev --===============5321314140487418340==--