Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: What does a list comprehension do Date: Thu, 26 Nov 2015 15:56:41 +0200 Organization: A noiseless patient Spider Lines: 22 Message-ID: <87fuzseuee.fsf@elektro.pacujo.net> References: <877fldnm9z.fsf@handshake.de> <87k2p4ex5x.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="16473"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eoLwNufMlbLwSpKsteJ0J" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:q/6T5CM4QHbfnP/scDUDfZcnoc0= sha1:o0enEAjkAB8ZGsUcEWQINACF0cU= Xref: csiph.com comp.lang.python:99576 Antoon Pardon : > I don't understand. What I propose would be a minor change in > how list comprehension works. I don't see how your example > can be turned into a list comprehension. The list comprehension is only a special case of the interaction between closures and variables. If you dabble with list comprehensions and lambdas, you'll need to make consistent changes in closure semantics. That would lead to the trouble I mentioned. Closures need to have dynamic access to the variables they refer to. This whole issue is a consequence of Python's assignment semantics. If Python didn't allow altering the values of variables, we wouldn't be having this discussion. BTW, all(!?) other languages from Java to Scheme share closure semantics with Python so you would really be making a mess by changing Python. Marko