Live data from Hacker News

10 Python One-liners To Impress Your Friends

codeblog.dhananjaynene.com

1–10 of 20 posts

Re: 10 Python One-liners To Impress Your Friends

#7
post #3

Why is number 1 better than just: [x*2 for x in range(1, 11)]

I felt the same about number 3.

  [x in tweet.split() for x in wordlist]
Seems better to me than

  map(lambda x: x in tweet.split(),wordlist)
Although the natural thing for me to do would be

  [x for x in wordlist if x in tweet]
Which both generates a list of words instead of booleans(['scala', 'sbt'] instead of [True, False, False, False, False]) and also matches the 'sbt' in tweet.
Post reply on HN