PEP scepticism

Andrew Dalke dalke at acm.org
Thu Jun 28 16:24:56 EDT 2001


Jason F. McBrayer wrote:
>>>>>> "RS" == Roman Suzi <rnd at onego.ru> writes:
>RS> There is limit after which more explanation is worse than less:
>
>RS> processed_list = []
>RS> for i in old_list:
>RS>   processed_list.append(func(i))
>
>RS> adds nothing but noise, while:
>
>In this trivial case, probably not, but...

A month or so I posted an example where I explained why I liked
list comprehensions

http://mail.python.org/pipermail/python-list/2001-May/042951.html

It boils down to that this trivial case occurs very frequently,
so I put the three lines or so into a function.  But I couldn't
think of a good function name.  By using list comprehensions
I traded off some strange syntax for the ability to describe
everything in one place - more legibility in the long run.

So my coding recommendation is to use list comprehensions solely
for that trivial case, and use functions for more complex ones.

                    Andrew






More information about the Python-list mailing list