[Python-ideas] Can you explain me why that is a bad idea?

Terry Reedy tjreedy at udel.edu
Fri Oct 25 21:54:03 CEST 2013


On 10/25/2013 10:12 AM, neuro wrote:
> I wrote to Guido on twitter this question
>
> Can you add this construction
 > for c in list if condition :
 >   suite
 > when suite block very big for list comprehension
>
> This is Guido answer:
> Someone on python-ideas at python.org
> <mailto:python-ideas at python.org> can
> probably explain why that is a bad idea.
>
> Can you explain me why that is a bad idea?

To start with, it is completely unnecessary as it would be the same as
for c in list:
   if condition:
     suite

Next add add in while condition blocks and the possibility of more than 
two blocks on a line. Things quickly get confusing.

Now consider adding an else: clause to your example. Would it belong to 
the for clause or to the if clause?

If we start down this road, why not allow 'try' also?

One compound statement header to a line is a good rule.

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list