[Python-ideas] Fwd: Fwd: unpacking generalisations for list comprehension

Nick Coghlan ncoghlan at gmail.com
Sun Oct 16 03:21:55 EDT 2016


On 16 October 2016 at 03:17, Random832 <random832 at fastmail.com> wrote:
> On Sat, Oct 15, 2016, at 06:38, Steven D'Aprano wrote:
>> > Replacing it _with the items_ is not the same thing as replacing it
>> > _with a sequence containing the items_,
>>
>> I don't think I ever used the phrasing "a sequence containing the
>> items". I think that's *your* phrase, not mine.
>
> It's not your phrasing, it's the actual semantic content of your claim
> that it would have to wrap them in a tuple.
>
>> The core developers have made it absolutely clear that changing the
>> fundamental equivalence of list comps as syntactic sugar for:
>>
>>     result = []
>>     for t in iterable:
>>         result.append(t)
>>
>>
>> is NOT NEGOTIABLE.
>
> I've never heard of this. It certainly never came up in this discussion.

It's not negotiable, and that most recently came up just a few weeks
ago: https://mail.python.org/pipermail/python-ideas/2016-September/042602.html

> And it was negotiable just fine when they got rid of the leaked loop
> variable.

We wrapped it in a nested function scope without otherwise changing
the syntactic equivalence, and only after generator expressions
already introduced the notion of using a nested scope (creating Python
2's scoping discrepancy between "[x for x in iterable]" and "list(x
for x in iterable)", which was eliminated in Python 3).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list