News for hackers. Stuff that matters.
Re:Python idioms I wish I'd learned earlier by misiti3780 on Thursday November 27, 2014 @01:11PM (#8668302)
i didnt realize you could add the if statement in the comprehension where you did

    ['a' if i % 2 == 0 else 'b' for i in range(10)]
very cool!

I was only aware of code like

    ['a' for i in range(10) if i % 2 == 0]

There are no comments on this comment yet.