Nelson Crosby wrote:
> I was thinking a bit about the following pattern:
>
> value = get_some_value()
> while value in undesired_values:
> value = get_some_value()
>
> I've always hated code that looks like this. Partly due to the repetition,
> but partly also due to the fact that without be
c...@isbd.net:
> Marko Rauhamaa wrote:
>> Chris Angelico :
>>
>> > You could deduplicate it by shifting the condition:
>> >
>> > while True:
>> > value = get_some_value()
>> > if value not in undesired_values: break
>> >
>> > But I'm not sure how common this idiom actually is.
>>
>> Ext
Marko Rauhamaa wrote:
> Chris Angelico :
>
> > You could deduplicate it by shifting the condition:
> >
> > while True:
> > value = get_some_value()
> > if value not in undesired_values: break
> >
> > But I'm not sure how common this idiom actually is.
>
> Extremely common, and not only i
Chris Angelico :
> On Fri, Dec 12, 2014 at 6:10 PM, Marko Rauhamaa wrote:
>> Chris Angelico :
>>
>>> You could deduplicate it by shifting the condition:
>>>
>>> while True:
>>> value = get_some_value()
>>> if value not in undesired_values: break
>>>
>>> But I'm not sure how common this id
On Fri, Dec 12, 2014 at 7:00 PM, Mark Lawrence wrote:
> It won't happen as different format loops have been discussed and rejected
> umpteen times over the last 20 odd years, mainly because the code can be
> restructured using break as others have already pointed out. Unless of
> course you fork
On 12/12/2014 02:21, Nelson Crosby wrote:
I was thinking a bit about the following pattern:
value = get_some_value()
while value in undesired_values:
value = get_some_value()
I've always hated code that looks like this. Partly due to the repetition, but
partly also due to the fact that wi
On Fri, Dec 12, 2014 at 6:10 PM, Marko Rauhamaa wrote:
> Chris Angelico :
>
>> You could deduplicate it by shifting the condition:
>>
>> while True:
>> value = get_some_value()
>> if value not in undesired_values: break
>>
>> But I'm not sure how common this idiom actually is.
>
> Extremel
Chris Angelico :
> You could deduplicate it by shifting the condition:
>
> while True:
> value = get_some_value()
> if value not in undesired_values: break
>
> But I'm not sure how common this idiom actually is.
Extremely common, and not only in Python.
Marko
--
https://mail.python.org
(Please don't top-post; instead, interleave responses inline with the
quoted material and trim the excess. See
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style>.)
"Clayton Kirkwood" writes:
> I would prefer:
> while value = initial_value in undesired_values:
> value = get_so
On 12/11/2014 9:21 PM, Nelson Crosby wrote:
I was thinking a bit about the following pattern:
value = get_some_value()
while value in undesired_values:
value = get_some_value()
This is do_while or do_until. In Python, write it as do_until in this form.
while True:
value = get_some_v
Of Ben Finney
>Sent: Thursday, December 11, 2014 6:38 PM
>To: python-list@python.org
>Subject: Re: Extension of while syntax
>
>Nelson Crosby writes:
>
>> I was thinking a bit about the following pattern:
>>
>> value = get_some_value()
>> while value in unde
On Fri, Dec 12, 2014 at 1:21 PM, Nelson Crosby wrote:
> I was thinking a bit about the following pattern:
>
> value = get_some_value()
> while value in undesired_values:
> value = get_some_value()
>
> I've always hated code that looks like this. Partly due to the repetition,
> but partly also
Nelson Crosby writes:
> I was thinking a bit about the following pattern:
>
> value = get_some_value()
> while value in undesired_values:
> value = get_some_value()
I think that's an anti-pattern (because of the repetition, as you say).
An improvement::
value = some_default_value_such_
I was thinking a bit about the following pattern:
value = get_some_value()
while value in undesired_values:
value = get_some_value()
I've always hated code that looks like this. Partly due to the repetition, but
partly also due to the fact that without being able to immediately recognise
th
14 matches
Mail list logo