On Thu, Apr 12, 2018 at 12:37 AM, Peter O'Connor
> Let's look at a task where there is "one obvious way"
> Suppose someone asks: "How can I build a list of squares of the first 100
> odd numbers [1, 9, 25, 49, ....] in Python?" The answer is now obvious -
> few people would do this:
> list_of_odd_squares = 
> for i in range(100):
> or this:
> def iter_odd_squares(n)):
> for i in range(n):
> yield (i*2+1)**2
> list_of_odd_squares = list(iter_odd_squares(100))
> Because it's just more clean, compact, readable and "obvious" to do:
> list_of_even_squares = [(i*2+1)**2 for i in range(100)]
> Maybe I'm being presumptuous, but I think most Python users would agree.
squares = [i**2 for i in range(1, 200, 2)]
So maybe even the obvious examples aren't quite as obvious as you might think.
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/