
My Favorite Pieces of Syntax in 8 Different Programming Languages - yakkomajuri
https://medium.com/@yakko.majuri/my-favorite-pieces-of-syntax-in-8-different-programming-languages-ba37b64fc232
======
perfunctory

      def even_numbers(limit):
        return [num for num in range(0, limit, 2)]
    

It’s unfortunate they chose this specific example because it doesn’t really
show the power of list comprehensions. This example could be written as

    
    
      return list(range(0, limit, 2))
    

Or even simply

    
    
      return range(0, limit, 2)
    

If one doesn’t need a mutable list.

~~~
yakkomajuri
Great point! Was trying to keep examples simple but that just flew over my
head. Updated the article. How about the new example?

def squares(limit): return [num*num for num in range(0, limit)]

If you have another suggestion I'd be happy to hear it!

~~~
perfunctory
Much better.

