# Re: [Python-ideas] Proposal: A Reduce-Map Comprehension and a "last" builtin

```On Thu, Apr 12, 2018 at 12:37 AM, Peter O'Connor
<peter.ed.ocon...@gmail.com> wrote:
> 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):
>         list_of_odd_squares.append((i*2+1)**2)
>
> 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.
>```
```
Or:

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.

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
```