News for hackers. Stuff that matters.
Re:Python 3.6.0 released by lyschoening on Friday December 23, 2016 @12:19PM (#13245870)
The pythonic (i.e. right) way to write this is:

    x = [i * 10 for i in [1, 2, 3]]
Re:Python 3.6.0 released by SeanDav on Friday December 23, 2016 @12:57PM (#13246133)

    i. let x = [ 1, 2, 3].map(i => i * 10)

    ii. x = list(map((lambda i: i * 10), [ 1, 2, 3 ]))

    iii. x = [i * 10 for i in [1, 2, 3]]
All these methods are really just multiple sides of the same coin. All I see is different syntax, none looks any better from my point of view and unless there is a clear performance benefit, just use what you are used to, or what your coding standards define.
Re:Python 3.6.0 released by lyschoening on Friday December 23, 2016 @01:22PM (#13246320)
ii. vs iii. boils down to explicit rather than implicit. iii. is simply easier to understand. I believe most people would also agree that ii. doesn't look particularly nice.
Re:Python 3.6.0 released by NegativeLatency on Friday December 23, 2016 @01:08PM (#13246217)
I think in general the comprehension is faster because of how method calls and symbol lookups work in python. For the most part it's just a style thing.
Re:Python 3.6.0 released by spraak on Friday December 23, 2016 @10:08PM (#13248366)
I understand superficially that this works, but can you explain the syntax (or is there a name for this)? So far I've also seen a for loop like

    for i in [1,2,3]:
        ...
Re:Python 3.6.0 released by spraak on Friday December 23, 2016 @11:46PM (#13248620)