On Mon, 26 Jan 2015 10:46:02 -0500 "R. David Murray" <rdmur...@bitdance.com> wrote:
> On Mon, 26 Jan 2015 09:43:26 -0500, Barry Warsaw <ba...@python.org> wrote: > > On Jan 25, 2015, at 09:31 PM, R. David Murray wrote: > > > > >> > > {*x for x in it} > > >> > > > > >> > > which is a set comprehension, while the other is a dict > > >> > > comprehension :) > > >> > > > > >> > > > >> > That distinction doesn't bother me -- you might as well claim it's > > >> > confusing that f(*x) passes positional args from x while f(**x) passes > > >> > keyword args. > > >> > > > >> > And the varargs set comprehension is similar to the varargs list > > >> > comprehension: > > >> > > > >> > [*x for x in it] > > >> > > > >> > If `it` were a list of three items, this would be the same as > > >> > > > >> > [*it[0], *it[1], *it[2]] > > >> > > >> I find all this unreadable and difficult to understand. > > > > > >I did too, before reading the PEP. > > > > > >After reading the PEP, it makes perfect sense to me. Nor is the PEP > > >complicated...it's just a matter of wrapping your head around the > > >generalization[*] of what are currently special cases that is going on > > >here. > > > > It does make sense after reading the PEP but it also reduces the readability > > and instant understanding of any such code. This is head-scratcher code > > that > > I'm sure I'd get asked about from folks who aren't steeped in all the dark > > corners of Python. I don't know if that's an argument not to adopt the PEP, > > but it I think it would be a good reason to recommend against using such > > obscure syntax, unless there's a good reason (and good comments!). > > But it is only obscure because we are not used to it yet. It is a > logical extension of Python's existing conventions once you think about > it. It will become "obvious" quickly, IMO. I have to agree with Barry. While the following is obvious even without having ever used it: a, b, *c = range(5) the following makes me scratch my head and I can't seem to guess what the *intent* is - which is very problematic when e.g. reviewing code: [*x for x in it] {**x for x in it} (and other similar things) I also think the multiple-starargs function calls are completely overboard: f(**someargs, **someotherargs) (I might add I've never felt any need for those) These generalizations look to me like a case of consistency taken too far. When some construct needs commenting to be understandable, then probably that construct shouldn't exist at all. (yes, I should have reacted earlier. I hadn't realized the PEP went that far. It seemed short and simple so I didn't look carefully :-)) By the way, when reading https://www.python.org/dev/peps/pep-0448/, I can't find a reference to the final pronouncement. Regards Antoine. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com