> So I am sorry for the spam. Will be careful the next time.

I wouldn't worry about it too much. :)

In future, if you can establish to some degree that:

1) The feature isn't already available (if you're unsure, try python-list
as suggested above)
2) It has some realistic use cases
3) It hasn't been already proposed (if so, prepare counterarguments using
past discussions)
4) It doesn't involve major breaking changes (if it does, prepare to
strongly justify why it's worth the breakage)

If you have the above points covered, then invest some time into thinking
about and writing up the post, you're pretty much good to go. Even if the
idea is something that will never be implemented, a rejected proposal can
often yield a substantial wealth of information or provide a spark of
inspiration for a similar idea.

On Mon, Mar 9, 2020 at 10:00 AM Shrinivas Kulkarni <shrin...@gmail.com>
wrote:

> Hi Rajeev and others
>
> Thanks for your responses. I completely overlooked the simple fact
> that the conditions are evaluated to boolean values and as such can be
> stored in variables.
> In the hindsight there may perhaps be a couple of (far-fetched) merits
> to my proposal (like useful in conditions with dynamic function calls
> or sparing users the effort of maintaining rather ephemeral variables)
> but they are of course not worth the effort of making a change to the
> language itself.
>
> So I am sorry for the spam. Will be careful the next time.
>
> Best regards
> Shrinivas Kulkarni
>
> On Mon, Mar 9, 2020 at 10:21 AM Rajeev J Sebastian
> <rajeev.sebast...@alokin.in> wrote:
> >
> > Hi Shrinivas,
> >
> > Wouldn’t these just be variables?
> >
> > Cond1 = color == Blue and count == 20
> > Cond2 = color == Red
> >
> > if cond1 or cond2:
> >       Do something
> > elif cond3:
> >        Do something else
> >
> > Regards
> > Rajeev J Sebastian
> > On 8 Mar 2020, 20:42 +0530, Shrinivas Kulkarni <shrin...@gmail.com>,
> 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 simplified example:
> >
> > ########################## Code ##########################
> > if (color == BLUE and count == 20) or (color == RED and count % 5 == 0):
> > rotate_the_wheel() # Common to the two sub-conditions
> > if(color == BLUE and count == 20): # First sub-condition
> > set_signal()
> > if(color == RED and count % 5 == 0): # Second sub-condition
> > clear_signal()
> > proc_post_rotate() # Common to the two sub-conditions
> >
> > I am not sure if there is a better way to do this. If not, maybe there
> > can be an extension to the language, which would allow marking a
> > sub-condition just like we mark a sub-expression in a regular
> > expression.
> >
> > Tentative syntax for this could be ({} marks the sub-condition and
> > \number refers back to it):
> >
> > ########################## Code ##########################
> > if {(color == BLUE and count == 20)} or {(color == RED and count % 5 ==
> 0)}:
> > rotate_the_wheel()
> > if(\1): # First marked condition
> > set_signal()
> > if(\2): # Second marked condition
> > unset_signal()
> > proc_post_rotate()
> >
> > And like sub-expressions, the nesting of marked sub-condions should
> > also be possible:
> >
> > ########################## Code ##########################
> > if {{(color == BLUE and count == 20)} and {value == 20}} or {(color ==
> > RED and count % 5 == 0)}:
> > if(\1):# Refers to the entire subcondition {{(color == BLUE and
> > count == 20)} and {value = 20}}
> > proc1()
> > if(\2):# Refers to sub-subcondition {value == 20}
> >
> > This will not only avoid the repetition of sub-conditions, but make
> > code readable since something like \1 will give an immediate
> > indication of a sub-condition that's defined earlier.
> >
> > Please let me know something similar is already implemented.
> > Even otherwise, all your thoughts, inputs and criticism are welcome.
> >
> > Thanks and best regards
> > Shrinivas Kulkarni
> > _______________________________________________
> > Python-ideas mailing list -- python-ideas@python.org
> > To unsubscribe send an email to python-ideas-le...@python.org
> > https://mail.python.org/mailman3/lists/python-ideas.python.org/
> > Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/M5OUL4RC4N4LNVRHFAWB75QXNLN7G7TP/
> > Code of Conduct: http://python.org/psf/codeofconduct/
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/7I3K725PUUDNIY4NDSLQGTRDTR32JQVV/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/SG6B4OR4QQBUPATLU6B42POK5F5EG7H4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to