Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99578

Re: What does a list comprehension do

From Antoon Pardon <antoon.pardon@rece.vub.ac.be>
Newsgroups comp.lang.python
Subject Re: What does a list comprehension do
Date 2015-11-26 15:26 +0100
Message-ID <mailman.141.1448548095.20593.python-list@python.org> (permalink)
References (3 earlier) <pan.2015.11.26.11.13.43.440000@nowhere.invalid> <mailman.132.1448538769.20593.python-list@python.org> <87k2p4ex5x.fsf@elektro.pacujo.net> <mailman.138.1448544914.20593.python-list@python.org> <87fuzseuee.fsf@elektro.pacujo.net>

Show all headers | View raw


Op 26-11-15 om 14:56 schreef Marko Rauhamaa:
> Antoon Pardon <antoon.pardon@rece.vub.ac.be>:
>
>> 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.

It would only dabble with the list comprehension not with the lambda.
The effect of the change would only be that a list comprehension like

    [ <expression> for <var> in <iter> ]

would implicitly be rewritten as follows:

    [ (lambda <var>: <expression>)(<var>) for <var> in <iter>]

There would no change on how lambdas work or functions or closures.

> BTW, all(!?) other languages from Java to Scheme share closure semantics
> with Python so you would really be making a mess by changing Python.

Not this proposal, which wouldn't touch closure semantics.

-- 
Antoon.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

What does a list comprehension do (was: Late-binding of function defaults (was Re: What is a function parameter =[] for?)) Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-25 14:51 +0100
  Re: What does a list comprehension do (was: Late-binding of function defaults (was Re: What is a function parameter =[] for?)) Nobody <nobody@nowhere.invalid> - 2015-11-26 11:13 +0000
    Re: What does a list comprehension do Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-26 12:52 +0100
      Re: What does a list comprehension do Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 14:56 +0200
        Re: What does a list comprehension do Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-26 14:33 +0100
          Re: What does a list comprehension do Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 15:56 +0200
            Re: What does a list comprehension do Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-26 15:26 +0100
              Re: What does a list comprehension do Marko Rauhamaa <marko@pacujo.net> - 2015-11-26 17:36 +0200
                Re: What does a list comprehension do Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-11-26 20:18 +0100
              Re: What does a list comprehension do Jussi Piitulainen <harvest@is.invalid> - 2015-11-26 18:11 +0200

csiph-web