Re: Extension of while syntax

2014-12-13 Thread Steven D'Aprano
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 being

Re: Extension of while syntax

2014-12-12 Thread Mark Lawrence
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

Re: Extension of while syntax

2014-12-12 Thread Chris Angelico
On Fri, Dec 12, 2014 at 7:00 PM, Mark Lawrence breamore...@yahoo.co.uk 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

Re: Extension of while syntax

2014-12-12 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: On Fri, Dec 12, 2014 at 6:10 PM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: 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

Re: Extension of while syntax

2014-12-12 Thread cl
Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: 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,

Re: Extension of while syntax

2014-12-12 Thread Marko Rauhamaa
c...@isbd.net: Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: 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.

Extension of while syntax

2014-12-11 Thread Nelson Crosby
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

Re: Extension of while syntax

2014-12-11 Thread Ben Finney
Nelson Crosby n...@sourcecomb.com 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 =

Re: Extension of while syntax

2014-12-11 Thread Chris Angelico
On Fri, Dec 12, 2014 at 1:21 PM, Nelson Crosby n...@sourcecomb.com 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

RE: Extension of while syntax

2014-12-11 Thread Clayton Kirkwood
: Thursday, December 11, 2014 6:38 PM To: python-list@python.org Subject: Re: Extension of while syntax Nelson Crosby n...@sourcecomb.com 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

Re: Extension of while syntax

2014-12-11 Thread Terry Reedy
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 =

Re: Extension of while syntax

2014-12-11 Thread Ben Finney
(Please don't top-post; instead, interleave responses inline with the quoted material and trim the excess. See URL:https://en.wikipedia.org/wiki/Posting_style#Interleaved_style.) Clayton Kirkwood c...@godblessthe.us writes: I would prefer: while value = initial_value in undesired_values:

Re: Extension of while syntax

2014-12-11 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: 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 --

Re: Extension of while syntax

2014-12-11 Thread Chris Angelico
On Fri, Dec 12, 2014 at 6:10 PM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: 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