On 2014-11-23, Roy Smith <r...@panix.com> wrote:
> In article <mailman.16191.1416757555.18130.python-l...@python.org>,
>  Skip Montanaro <skip.montan...@gmail.com> wrote:
>> > But it breaks all the picture that I've built in my head about comps till
>> > now...
>> 
>> Note that list comprehensions are little more than syntactic sugar for for
>> loops. If you're having terrible writing or understanding one, especially a
>> compound one like your example, it can help to write it as a (nested) for
>> loop, then covert it (perhaps incrementally) to the list comp form.
>
> Or not.  If it was complicated enough that you needed to loopify it to 
> understand what it's doing, have pity on the next person who has to 
> maintain your code and leave it as a loop :-)
>
> My general rule for code hygiene is, "If I have to think about whether 
> something is too complicated, it is".

My reminder rule for nested comprehensions is "Which way do you
instinctively think they should nest and makes logical sense?
They don't work that way."
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to