Re: [Python-ideas] Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-09 Thread David Mertz
This isn't a terrible use of the walrus operator either. if blue_20 := (color==BLUE and count==20) or red_5 := (color==RED and count%5==0) rotate_the_wheel() # Common to the two sub-conditions if blue_20: # First sub-condition set_signal() if red_5: # Second sub-condition

Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-08 Thread Terry Reedy
On 3/8/2020 12:07 PM, MRAB wrote: In Python 3.8+ there's the "walrus operator" which lets you assign within an expression: if (first := (color == BLUE and count == 20)) or (second := (color == RED and count % 5 == 0)):     rotate_the_wheel()     if first:     set_signal()     if seco

Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-08 Thread DL Neil via Python-list
On 8/03/20 11:05 PM, Shrinivas Kulkarni wrote: Hello Everyone While writing python code, I frequently come across the need to do certain tasks based on combined conditions. Much of the task for all the sub-conditions are common but some are specific to one or more of these sub-conditions. The

Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-08 Thread MRAB
On 2020-03-08 10:05, Shrinivas Kulkarni wrote: Hello Everyone While writing python code, I frequently come across the need to do certain tasks based on combined conditions. Much of the task for all the sub-conditions are common but some are specific to one or more of these sub-conditions. A si

Re: Possible Addition to Python Language: Marked Sub-condition

2020-03-08 Thread Paul Moore
On Sun, 8 Mar 2020 at 15:02, Shrinivas Kulkarni wrote: > > Hello Everyone > > While writing python code, I frequently come across the need to do > certain tasks based on combined conditions. > > Much of the task for all the sub-conditions are common but some are > specific to one or more of these