
PEP 8 currently lacks any suggestions for how multi-line generator expressions and list comprehensions should be formatted. In the absence of any official style suggestion (that I can find), I suggest the style used the most in the standard library. [<expression> for <target_list> in <container> if <condition>] Note, lines could still be combined where it makes sense, eg, the first two lines could be combined if they aren't too long. -- "Evil begins when you begin to treat people as things." - Terry Pratchett

On 09/14/2013 07:36 AM, Clay Sweetser wrote:
PEP 8 currently lacks any suggestions for how multi-line generator expressions and list comprehensions should be formatted. In the absence of any official style suggestion (that I can find), I suggest the style used the most in the standard library.
[<expression> for <target_list> in <container> if <condition>]
Note, lines could still be combined where it makes sense, eg, the first two lines could be combined if they aren't too long.
But that amounts to simply respecting the line length limit and using logical breakpoints. I don't think that requires a special mention in PEP 8. cheers, Georg

On Sep 14, 2013, at 07:49 AM, Georg Brandl wrote:
On 09/14/2013 07:36 AM, Clay Sweetser wrote:
PEP 8 currently lacks any suggestions for how multi-line generator expressions and list comprehensions should be formatted. In the absence of any official style suggestion (that I can find), I suggest the style used the most in the standard library.
[<expression> for <target_list> in <container> if <condition>]
Note, lines could still be combined where it makes sense, eg, the first two lines could be combined if they aren't too long.
But that amounts to simply respecting the line length limit and using logical breakpoints. I don't think that requires a special mention in PEP 8.
Agreed. -Barry
participants (3)
-
Barry Warsaw
-
Clay Sweetser
-
Georg Brandl