Re: Hack or beauty?
[email protected] (Stefan Ram) 13 May 2026 19:33:41 GMT
| Newsgroups | comp.lang.python |
|---|---|
| Organization | Stefan Ram |
| Message-ID | <[email protected]> |
"Michael F. Stemper" <[email protected]> wrote or quoted: >for variable in angles if options.angle else comps: It seems it's not allowed in a list comprehension without additional parentheses. d = 1 l = [] for i in range( 3 )if d else range( 5 ): l.append( i ) print( l ) print( [ i for i in( range( 3 )if d else range( 5 ))] ) . To me, your, for variable in angles if options.angle else comps: , is fine, but I think what would be a bit clearer might be, variables = angles if options.angle else comps for variable in variables: .