On 2022-12-18 16:49:27 +, Stefan Ram wrote:
> Dennis Lee Bieber 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:
> >
On Saturday, 17 December 2022 at 23:58:11 UTC, avi.e...@gmail.com wrote:
> Is something sort of taboo when using something like a computer language to
> write a program?
With what else would you write a program?
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, 14 Dec 2022 10:53:10 -0800 (PST), Aaron P
declaimed the following:
Late response here, and the concept may have been covered in
skimmed-over posts..
>I occasionally run across something like:
>
>for idx, thing in enumerate(things):
>if idx == 103:
>continue
>do_s
On Sun, 18 Dec 2022 at 10:59, wrote:
>
> If a compiler or interpreter HAPPILY (as happy as machines/code get) compiles
> or interprets your code without errors every time you use it a certain way,
> then it is not wrong to use it. Of course if it subject to change or already
> deprecated, ...
>
er that it is best seen as multiple lines. It
may be legal but is best used to obfuscate!
The problem with some RULES is that not only are they not real rules but
sometimes have exceptions where they get in the way of getting things done.
- Avi
-----Original Message-
From: Python-list On
Behalf Of
lem with some RULES is that not only are they not real rules but
sometimes have exceptions where they get in the way of getting things done.
- Avi
-Original Message-
From: Python-list On
Behalf Of Rob Cliffe via Python-list
Sent: Thursday, December 15, 2022 8:31 AM
To: python-list@python.or
On 16/12/2022 02.30, Rob Cliffe via Python-list wrote:
On 15/12/2022 04:35, Chris Angelico wrote:
On Thu, 15 Dec 2022 at 14:41, Aaron P
wrote:
I occasionally run across something like:
for idx, thing in enumerate(things):
if idx == 103:
continue
do_something_with(thing)
It
Just wanted to say that a silent reader like me learnt more about PEP-8
solely from this thread than my mentor at work or any other course I have
taken earlier this year. Thank you so much.
On Sun, 18 Dec 2022, 00:16 Rob Cliffe via Python-list, <
python-list@python.org> wrote:
>
>
> On 15/12/2022
On 15/12/2022 04:35, Chris Angelico wrote:
On Thu, 15 Dec 2022 at 14:41, Aaron P wrote:
I occasionally run across something like:
for idx, thing in enumerate(things):
if idx == 103:
continue
do_something_with(thing)
It seems more succinct and cleaner to use:
if idx == 10
On 2022-12-15, MRAB wrote:
> A problem with having a single return is that it can lead to excessive
> indentation:
>
> if test_1:
> ...
>
> if test_2:
> ...
>
> if test_3:
> ...
>
> return
I sometimes have to work on code li
On 12/15/2022 3:58 AM, Chris Green wrote:
Thomas Passin wrote:
I personally tend to use
if test: return
even inside larger blocks.
I always try to avoid multiple returns from functions/methods, as soon
as things get complex it's all to easy to miss clean-up etc.
"No mul
: Python-list On
Behalf Of Stefan Ram
Sent: Thursday, December 15, 2022 7:42 AM
To: python-list@python.org
Subject: Re: Single line if statement with a continue
Chris Green writes:
I always try to avoid multiple returns from functions/methods, as soon
as things get complex it's all to easy to
easily handled by the try / finally construct.
From: Python-list on
behalf of avi.e.gr...@gmail.com
Date: Thursday, December 15, 2022 at 2:07 PM
To: python-list@python.org
Subject: RE: Single line if statement with a continue
*** Attention: This is an external email. Use caution responding
points are bad, but that they
are often a symptom of sloppy planning. But for some problems, they fit well
and simplify things.
-Original Message-
From: Python-list On
Behalf Of Stefan Ram
Sent: Thursday, December 15, 2022 7:42 AM
To: python-list@python.org
Subject: Re: Single line if
r...@zedat.fu-berlin.de (Stefan Ram) writes:
>>"No multiple returns" is often found in programming guidelines.
>
> I religiously followed that when I did more C programming
> than today. Then, I read an article about how the result
> pattern makes functions measurably slower. (It should not
Thomas Passin wrote:
>I personally tend to use
>
> if test: return
>
> even inside larger blocks.
I always try to avoid multiple returns from functions/methods, as soon
as things get complex it's all to easy to miss clean-up etc.
"No multiple returns" is often found in prog
27;s code.
-Original Message-
From: Python-list On
Behalf Of dn
Sent: Thursday, December 15, 2022 12:24 AM
To: python-list@python.org
Subject: Re: Single line if statement with a continue
On 15/12/2022 07.53, Aaron P wrote:
> I occasionally run across something like:
>
> for idx, thing
On Thu, 15 Dec 2022 at 16:29, Thomas Passin wrote:
>
> PEP-8, which is Guido's style guide and generally good to follow, does
> not completely discourage single-line usage like the example. It's not
> clear to me how Chris's example fits into the guidelines.
>
> PEP-8:
> "While sometimes it’s oka
PEP-8, which is Guido's style guide and generally good to follow, does
not completely discourage single-line usage like the example. It's not
clear to me how Chris's example fits into the guidelines.
PEP-8:
"While sometimes it’s okay to put an if/for/while with a small body on
the same line,
On 15/12/2022 07.53, Aaron P wrote:
I occasionally run across something like:
for idx, thing in enumerate(things):
if idx == 103:
continue
do_something_with(thing)
It seems more succinct and cleaner to use:
if idx == 103: continue.
Of course this would be considered an anti
On Thu, 15 Dec 2022 at 14:41, Aaron P wrote:
>
> I occasionally run across something like:
>
> for idx, thing in enumerate(things):
> if idx == 103:
> continue
> do_something_with(thing)
>
> It seems more succinct and cleaner to use:
>
> if idx == 103: continue.
>
> Of course this
21 matches
Mail list logo