Comprehension with two variables - explanation needed

Skip Montanaro skip.montanaro at gmail.com
Sun Nov 23 16:45:47 CET 2014


> 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.

Skip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141123/464235c2/attachment.html>


More information about the Python-list mailing list