On Thu, Oct 13, 2016 at 11:42 PM Paul Moore <p.f.mo...@gmail.com> wrote:
> I remain puzzled.
> Given the well-documented and understood transformation:
> [fn(x) for x in lst if cond]
> translates to
> result = 
> for x in lst:
> if cond:
> please can you explain how to modify that translation rule to
> incorporate the suggested syntax?
if you allow result.append(1, 2, 3) to mean result.extend([1,2,3]) # which
was discussed before
result = 
for x in lst:
Or simply use result.extend([*fn(x)])
Personally, I'm not even sure any more that I can *describe* the
> suggested syntax. Where in [fn(x) for x in lst if cond] is the *
> allowed? fn(*x)? *fn(x)? Only as *x with a bare variable, but no
> expression? Only in certain restricted types of construct which aren't
> expressions but are some variation on an unpacking construct?
The star is always exactly at the place that should "handle" it. which
means [*(fn(x)) for x in lst if cond]. fn(x) must be iterable as always.
> We've had a lot of examples. I think it's probably time for someone to
> describe the precise syntax (as BNF, like the syntax in the Python
> docs at
> and following sections) and semantics (as an explanation of how to
> rewrite any syntactically valid display as a loop). It'll have to be
> done in the end, as part of any implementation, so why not now?
I will be happy to do so, and will be happy to work with anyone else
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/