Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197785

Re: Hack or beauty?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups comp.lang.python
Subject Re: Hack or beauty?
Date 13 May 2026 19:33:41 GMT
Organization Stefan Ram
Lines 27
Expires 1 Mar 2027 11:59:58 GMT
Message-ID <if-20260513203200@ram.dialup.fu-berlin.de> (permalink)
References <10u2hla$2tnlr$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de MGk2/ICl0HozgyRSkriWugDJjQ4JZsN4JnILLM1S86ShU6
Cancel-Lock sha1:3fi0fj6PLYQIZd7Mz089I+mmQA4= sha256:WcvQH/O8SZUSnGd4GG7hdGXsfcHf121VZjAC2p25RxU=
X-Copyright (C) Copyright 2026 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change URIs of this article into links, and to transfer the body without this notice, but quotations of parts in other Usenet posts are allowed.
X-No-Archive Yes
Archive no
X-No-Archive-Readme "X-No-Archive" is set, because this prevents some services to mirror the article in the web. But the article may be kept on a Usenet archive server with only NNTP access.
X-No-Html yes
Content-Language en
Xref csiph.com comp.lang.python:197785

Show key headers only | View raw


"Michael F. Stemper" <michael.stemper@gmail.com> 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: 

  .

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Hack or beauty? "Michael F. Stemper" <michael.stemper@gmail.com> - 2026-05-13 13:58 -0500
  Re: Hack or beauty? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-05-13 19:33 +0000
    Re: Hack or beauty? ram@zedat.fu-berlin.de (Stefan Ram) - 2026-05-13 21:04 +0000
      Re: Hack or beauty? Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-14 01:06 +0000
    Re: Hack or beauty? "Michael F. Stemper" <michael.stemper@gmail.com> - 2026-05-14 13:25 -0500
  Re: Hack or beauty? Mark Bourne <nntp.mbourne@spamgourmet.com> - 2026-05-13 21:52 +0100
    Re: Hack or beauty? "Michael F. Stemper" <michael.stemper@gmail.com> - 2026-05-14 08:06 -0500
  Re: Hack or beauty? Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-13 21:37 +0000

csiph-web