Can you explain me why that is a bad idea?

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@python.org can probably explain why that is a bad idea. Can you explain me why that is a bad idea? with best regards, Abu Sultanov

On Sat, Oct 26, 2013 at 1:12 AM, neuro <neurofag@gmail.com> wrote:
Well, firstly, it's generally better to take things to a mailing list than to personally email the BDFL :) You're fortunate - seems you got a reply (and a courteous and helpful one at that); most busy people would just delete your email and move on. As to the "for... in... if" sequence - it's been discussed quite a few times. It might seem nice and clean in simple cases, but invariably you come up against some messy edge cases before long. The first one to deal with is the parser ambiguity with the ternary operator. ChrisA

On 10/25/2013 10:12 AM, neuro wrote:
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

On Sat, Oct 26, 2013 at 1:12 AM, neuro <neurofag@gmail.com> wrote:
Well, firstly, it's generally better to take things to a mailing list than to personally email the BDFL :) You're fortunate - seems you got a reply (and a courteous and helpful one at that); most busy people would just delete your email and move on. As to the "for... in... if" sequence - it's been discussed quite a few times. It might seem nice and clean in simple cases, but invariably you come up against some messy edge cases before long. The first one to deal with is the parser ambiguity with the ternary operator. ChrisA

On 10/25/2013 10:12 AM, neuro wrote:
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
participants (4)
-
Chris Angelico
-
neuro
-
Paul Moore
-
Terry Reedy