On Tue, Oct 26, 2021 at 1:10 PM David Mertz, Ph.D.
<david.me...@gmail.com> wrote:
>
> I like this. I think explicitly discussing order of inclusion would be 
> worthwhile. I know it's implied by the approximate equivalents, but actually 
> stating it would improve the PEP, IMO.
>
> For example:
>
> nums = [(1, 2, 3), (1.0, 2.0, 3.0)]
> nset = {*n for n in nums}
>
> Does 'nset' wind up containing integers or floats? Is this a language 
> guarantee?
>

Easy way to find out: take out the extra nesting level and try it.

>>> nums = [1, 2, 3, 1.0, 2.0, 3.0]
>>> nset = {n for n in nums}
>>> nset
{1, 2, 3}

The *n version would have the exact same behaviour, since it will see
the elements in the exact same order.

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

Reply via email to