I do get what it does, but the phrase in the PEP feels like there is wiggle room: "The new notation listed above is effectively short-hand for the following existing notation." "Effectively" doesn't quite feel the same as "guaranteed exactly equivalent." On Mon, Oct 25, 2021, 10:22 PM Chris Angelico <rosuav@gmail.com> wrote:
On Tue, Oct 26, 2021 at 1:10 PM David Mertz, Ph.D. <david.mertz@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-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/2QCOFW... Code of Conduct: http://python.org/psf/codeofconduct/