What is the pythonic way to handle the situation where if a condition
exists the loop should be executed, but if it does not something else
should be done?
Why am I asking?
Today's code review included a for...else structure. I've rarely seen
such a thing, and even knowing it exists, cannot r
Would it be a hyphythonitical question?
=
Footnote:
Zamboni locks up after running into large patch of loose teeth.
-Original Message-
From: Python-list On
Behalf Of DL Neil
Sent: Monday, February 4, 2019 11:29 PM
To: 'Python'
Subject: Loop with else claus
...
=
Footnote:
Zamboni locks up after running into large patch of loose teeth.
-Original Message-
From: Python-list On
Behalf Of DL Neil
Sent: Monday, February 4, 2019 11:29 PM
To: 'Python'
Subject: Loop with else clause
What is the pythonic way to handle the situa
DL Neil writes:
> Possible solution:
> To make anything more than the trivial case readable, I think I'd put
> the list processing into one function, and the exception into another
> (except that this case is so trivial), ie
>
> if list:
> process_list() #the heading and for-l
DL Neil wrote:
> What is the pythonic way to handle the situation where if a condition
> exists the loop should be executed, but if it does not something else
> should be done?
> Possible solution:
> To make anything more than the trivial case readable, I think I'd put
> the list processing into
org] On Behalf Of
Peter Otten
Sent: Tuesday, February 05, 2019 3:44 AM
To: python-list@python.org
Subject: Re: Loop with else clause
DL Neil wrote:
> What is the pythonic way to handle the situation where if a condition
> exists the loop should be executed, but if it does not something
I don't know if it is very Pythonic, but I would do something like
if no_oscar_nominees:
print ("Sorry ...")
else:
print_list_of_oscar_nominees()
And yes, that for/else construct can be confusing.
Adriaan.
>>> On 5-2-2019 at 5:29, DL Neil
wrote:
> What is the pythonic way to handl
The topic is how to deal with a python loop that may not be run if you want
something else to happen in that case. Multiple solutions are presented
along with this request:
> Is there another, more pythonic, approach to conditional (for/while)
> loop processing?
Has anyone considered looking at
-Original Message-
From: Python-list On
Behalf Of DL Neil
Sent: Monday, February 4, 2019 11:29 PM
To: 'Python'
Subject: Loop with else clause
What is the pythonic way to handle the situation where if a condition exists
the loop should be executed, but if it does not some
Further to our discussion of how to improve a code review's discovery of
the mistaken handling of a for...else... construct:-
Yesterday was a national holiday, but today gave some opportunity to
research. Way back in 2009 there was spirited discussion over on the
Python Ideas list (warning, e
Wow, you dug deep.
My example was the reverse of the "toy example"'s you mention as I find
that often code becomes much clearer if you order it such that
specific cases, sanity checking and exceptions go first, and then the
default case at the end.
So my general suggestion would be to handle yo
Possibly the final contribution:-
On 9/02/19 1:30 AM, Adriaan Renting wrote:
Wow, you dug deep.
=Thank you. It started to 'bug' me, so I really was 'scratching an itch'!
My example was the reverse of the "toy example"'s you mention as I find
that often code becomes much clearer if you ord
12 matches
Mail list logo