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

On Sun, 8 Mar 2020 at 15:02, Shrinivas Kulkarni <shrinivk@gmail.com> wrote:
I would have thought that simply naming the sub-conditions would be sufficient. blue_20 = (color == BLUE and count == 20) red_5 = (color == RED and count % 5 == 0) if blue_20 or red_5: rotate_the_wheel() # Common to the two sub-conditions if blue_20: # First sub-condition set_signal() if red_5: # Second sub-condition clear_signal() proc_post_rotate() # Common to the two sub-conditions I don't know how experienced you are with Python programming, but if you had framed your question as "how do I modify this code to avoid repeating the conditions?" you would likely have been given this advice on the python-list mailinglist, or other similar Python programming help resources. Starting with a proposed language change before you've explored the existing options isn't likely to be the best approach (and would likely have meant you could resolve your issue without needing to bring it to python-ideas at all). Paul

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 clear_signal() proc_post_rotate() # Common to the two sub-conditions On Sun, Mar 8, 2020 at 12:02 PM Paul Moore <p.f.moore@gmail.com> wrote:
-- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.

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 clear_signal() proc_post_rotate() # Common to the two sub-conditions On Sun, Mar 8, 2020 at 12:02 PM Paul Moore <p.f.moore@gmail.com> wrote:
-- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.
participants (3)
-
David Mertz
-
MRAB
-
Paul Moore