Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Technology is dominated by those who manage what they do not understand.


devel / comp.lang.python / Re: Single line if statement with a continue

SubjectAuthor
* Single line if statement with a continueAaron P
+- Re: Single line if statement with a continueStefan Ram
+- Re: Single line if statement with a continueChris Angelico
+- Re: Single line if statement with a continuedn
+* Re: Single line if statement with a continueThomas Passin
|`* Re: Single line if statement with a continueChris Green
| +* Re: Single line if statement with a continueStefan Ram
| |+- Re: Single line if statement with a continueCecil Westerhof
| |+- RE: Single line if statement with a continue<avi.e.gross
| |+- Re: Single line if statement with a continueWeatherby,Gerard
| |+* Re: Single line if statement with a continueMRAB
| ||`- Re: Single line if statement with a continueStefan Ram
| |`- Re: Single line if statement with a continueGrant Edwards
| `- Re: Single line if statement with a continueThomas Passin
+- Re: Single line if statement with a continueChris Angelico
+- RE: Single line if statement with a continue<avi.e.gross
+- Re: Single line if statement with a continueRob Cliffe
+- Re: Single line if statement with a continueAbdullah Nafees
+- Re: Single line if statement with a continuedn
+* RE: Single line if statement with a continue<avi.e.gross
|`- Re: Single line if statement with a continueTony Oliver
+- Re: Single line if statement with a continueThomas Passin
+- Re: Single line if statement with a continueChris Angelico
`* Re: Single line if statement with a continueDennis Lee Bieber
 `* Re: Single line if statement with a continueStefan Ram
  `- Re: Single line if statement with a continuePeter J. Holzer

Pages:12
Re: Single line if statement with a continue

<mailman.1248.1671451310.20444.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=25206&group=comp.lang.python#25206

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: hjp-python@hjp.at (Peter J. Holzer)
Newsgroups: comp.lang.python
Subject: Re: Single line if statement with a continue
Date: Mon, 19 Dec 2022 13:01:41 +0100
Lines: 64
Message-ID: <mailman.1248.1671451310.20444.python-list@python.org>
References: <af8635f1-30b9-4a0b-b9f8-d81f2c54960an@googlegroups.com>
<cbeuph57qc2u30a5l4pk2ij8t9l3cno9le@4ax.com>
<loop-20221218174906@ram.dialup.fu-berlin.de>
<20221219120141.4geegs2aq4or37b3@hjp.at>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
protocol="application/pgp-signature"; boundary="y7c5hqxzvs3ied5n"
X-Trace: news.uni-berlin.de gxVTokIWpMh/2YIqDqu99wNeiartFa67zksez2qVys/g==
Return-Path: <hjp-python@hjp.at>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'content-
type:multipart/signed': 0.05; 'ram': 0.07; 'content-
type:application/pgp-signature': 0.09; 'filename:fname piece:asc':
0.09; 'filename:fname piece:signature': 0.09;
'filename:fname:signature.asc': 0.09; 'obviously': 0.09;
'readable': 0.09; 'writes:': 0.09; '"creative': 0.16; '"fail':
0.16; '__/': 0.16; 'challenge!"': 0.16; 'condition.': 0.16;
'follows': 0.16; 'from:addr:hjp-python': 0.16; 'from:addr:hjp.at':
0.16; 'from:name:peter j. holzer': 0.16; 'hjp@hjp.at': 0.16;
'holzer': 0.16; 'reality.': 0.16; 'stross,': 0.16;
'subject:continue': 0.16; 'url-ip:212.17.106.137/32': 0.16; 'url-
ip:212.17.106/24': 0.16; 'url-ip:212.17/16': 0.16; 'url:hjp':
0.16; '|_|_)': 0.16; 'wrote:': 0.16; 'larger': 0.17; 'probably':
0.17; 'to:addr:python-list': 0.20; 'code': 0.23; 'lines': 0.23;
"i'd": 0.24; 'cannot': 0.25; 'stefan': 0.26; 'function': 0.27;
'sense': 0.28; 'example,': 0.28; 'program,': 0.31; 'putting':
0.31; 'program': 0.31; 'said,': 0.32; 'but': 0.32; 'there': 0.33;
'same': 0.34; 'skip:" 20': 0.34; 'header:In-Reply-To:1': 0.34;
'main': 0.37; 'single': 0.39; 'still': 0.40; 'program.': 0.40;
'something': 0.40; 'four': 0.60; 'included': 0.61; '8bit%:20':
0.61; 'above': 0.62; 'received:212': 0.62; 'complete': 0.64;
'received:userid': 0.66; 'url-ip:212/8': 0.69; 'quotation': 0.84;
'received:at': 0.84
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <loop-20221218174906@ram.dialup.fu-berlin.de>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <20221219120141.4geegs2aq4or37b3@hjp.at>
X-Mailman-Original-References: <af8635f1-30b9-4a0b-b9f8-d81f2c54960an@googlegroups.com>
<cbeuph57qc2u30a5l4pk2ij8t9l3cno9le@4ax.com>
<loop-20221218174906@ram.dialup.fu-berlin.de>
 by: Peter J. Holzer - Mon, 19 Dec 2022 12:01 UTC
Attachments: signature.asc (application/pgp-signature)

On 2022-12-18 16:49:27 +0000, Stefan Ram wrote:
> Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:
> >>for idx, thing in enumerate(things):
> >> if idx == 103:
> >> continue
> >> do_something_with(thing)
> >>
> > For this example, I'd probably reverse the condition.
> > if idx != 103:
> > do_something_with(thing)
>
> The first four lines of the quotation above cannot be a
> complete program as "do_something_with" is not defined
> therein, so they must be part of a larger program.
> If, in this larger program, something still follows
> "do_something_with(thing)" in the loop, the new program
> after the transformation might not show the same behavior.

“do_something_with(thing)” is obviously not intended to be a single
function call but as a shorthand for “one or more lines of code which do
something with `thing`”. So there is nothing after it because it is
included in it.

That said, the "fail and bail" technique is often more readable than
putting the main incode inside of an if - especially if that code is
long and/or it is guarded by multiple conditions.

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

Attachments: signature.asc (application/pgp-signature)

devel / comp.lang.python / Re: Single line if statement with a continue

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor