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
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
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
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
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
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 simplified example:
## Cod