Hello all, Please Dom Grigonis add choices : - "No preference" choice to first question - "I don't know" or "I can't tell" to third question And I will answer to your poll and probably other people will feel and do the same. I agree that question 2 makes me prefer C syntax. But C is not the nicest syntax in my point of view. In MySQL SQL, there is IF(condition, if_result, else_result) which I find nice. Moreover, it fits well with black style of formatting: foo_var = IF( this_is_a very_long_condition_expression_which_may_have_nested_parts, this_is_a very_long_if_result_expression_which_may_have_nested_parts, this_is_a very_long_else_result_expression_which_may_have_nested_parts, ) to compare with : foo_var = ( this_is_a very_long_condition_expression_which_may_have_nested_parts, ? this_is_a very_long_if_result_expression_which_may_have_nested_parts, : this_is_a very_long_else_result_expression_which_may_have_nested_parts, ) I can enjoy both, but I prefer the SQL apart from the fact that "IF" keyword would be ambiguous. I also enjoy very much : foo_var = CASE WHEN condition THEN if_result WHEN condition2 THEN elif_result ELSE else_result END from SQL. And CASE is not a reserved keyword and WHEN, THEN, ELSE could have specific meaning inside of case. Truly, I would enjoy the following syntax for Python à la black : foo_var = case( when condition then if_result when condition2 then elif_result else else_result ) or even more concise and still readable : foo_var = case( condition : if_result, condition2 : elif_result, else_result, )
Best regards, Laurent Lyaudet Le lun. 17 juil. 2023 à 22:42, <python-ideas-requ...@python.org> a écrit : > > Message: 2 > Date: Mon, 17 Jul 2023 23:41:25 +0300 > From: Dom Grigonis <dom.grigo...@gmail.com> > Subject: [Python-ideas] Conditional 1-line expression in python > To: python-ideas <python-ideas@python.org> > Message-ID: <31303e8b-05a4-408b-af4d-916f805b5...@gmail.com> > Content-Type: multipart/alternative; > boundary="Apple-Mail=_41C44739-410D-45EA-89FF-6E2F1AF86836" > > Hi everyone, > > I am not very keen on long discussions on such matter as I do not think there > is much to discuss: there is no technical complexity in it and it doesn’t > really change or introduce anything new. It is only a matter of opinion & > style/design preferences with respect to logical order and brevity of a > statement. > > So I thought, if anyone can be bothered on such question and instead of > writing 3-minute e-mail, would take few seconds to answer 3-question poll. > > https://q5yitzu62.supersurvey.com <https://q5yitzu62.supersurvey.com/> > > Would be interesting to see if my preference is an outlier or not really. > > > Kind regards, > D. Grigonis > > > -------------- next part -------------- > A message part incompatible with plain text digests has been removed ... > Name: not available > Type: text/html > Size: 1499 bytes > Desc: not available > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > 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/ > > > ------------------------------ > > End of Python-ideas Digest, Vol 200, Issue 34 > ********************************************* _______________________________________________ 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/F3D6T4AEQLFIK7B3AXTUAJERI3BANMHP/ Code of Conduct: http://python.org/psf/codeofconduct/