[Python-Dev] The `for y in [x]` idiom in comprehensions
Michel Desmoulin
desmoulinmichel at gmail.com
Sun Feb 25 09:32:36 EST 2018
More information about the Python-Dev mailing list
Sun Feb 25 09:32:36 EST 2018
- Previous message (by thread): [Python-Dev] The `for y in [x]` idiom in comprehensions
- Next message (by thread): [Python-Dev] The `for y in [x]` idiom in comprehensions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Le 25/02/2018 à 14:11, Nikolaus Rath a écrit : > On Feb 25 2018, Chris Angelico <rosuav at gmail.com> wrote: >> On Sun, Feb 25, 2018 at 11:02 PM, Nikolaus Rath <Nikolaus at rath.org> wrote: >>> On Feb 22 2018, Serhiy Storchaka <storchaka at gmail.com> wrote: >>>> 1. Inner generator expression: >>>> >>>> result = [y + g(y) for y in (f(x) for x in range(10))] >>>> >>> [...] >>>> >>>> And maybe there are other ways. >>> >>> I think the syntax recently brough up by Nick is still the most >>> beautiful: >>> >>> result = [ (f(x) as y) + g(y) for x in range(10)] Honestly I find this version the most readable while the double for loop is completely weird to me, despite doing python for a living for years. I really hope the later doesn't become a common idiom.
- Previous message (by thread): [Python-Dev] The `for y in [x]` idiom in comprehensions
- Next message (by thread): [Python-Dev] The `for y in [x]` idiom in comprehensions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list