[Python-ideas] Re: Conditional 1-line expression in python

2023-08-05 Thread Rob Cliffe via Python-ideas

When can we expect the results of your survey?  (I responded to it.)
Best wishes
Rob Cliffe

On 17/07/2023 21:41, Dom Grigonis wrote:

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

Would be interesting to see if my preference is an outlier or not really.


Kind regards,
D. Grigonis



___
Python-ideas mailing list --python-ideas@python.org
To unsubscribe send an email topython-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived 
athttps://mail.python.org/archives/list/python-ideas@python.org/message/NZVLR56BFMBJXE6GN2GWRXIG6ZVAAWZZ/
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/4HTSS5AJC2RKKQVSM7RJDPIKIP4G7KWI/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Conditional 1-line expression in python

2023-08-05 Thread Chris Angelico
On Sat, 5 Aug 2023 at 22:49, Dom Grigonis  wrote:
> 3. The Python syntax is easily understandable to anyone who knows English as 
> it follows English syntax: "What are you doing tonight?" "I'm going to the 
> movies, if I manage to leave work on time, otherwise I'll just stay home.”
>   * Is the english sentence “If I manage to leave work on time, I’m going to 
> the movies, otherwise, I’ll just stay home” incorrect?

This is a VERY common objection to Python's syntax. No, the English
sentence you provide isn't wrong, and the "follows English syntax"
argument is not saying that C's way of laying it out is wrong. English
happily supports both orders. But that's a relatively weak
justification, since this is the same English that has a purple fruit
called a "grape", and then a completely different fruit in a different
family called a "grapefruit"; and where there's no well-accepted word
for "the day after tomorrow", but after some incidents in Prague, came
up with the glorious word "defenestration", which can also refer to
shutting down your GUI and returning to terminal mode. So I would say
this is only really of value as a rebuttal to "Python's conditional
syntax makes no sense", by saying "yeah well, it's no worse than
English".

Which is kinda like saying "banging your head against a wall doesn't
hurt **that** much, it's not as bad as maintaining a PHP web site.".

ChrisA
___
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/72VRUQKNWFLCL4KJFBIXYFT2DCX57PNY/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Conditional 1-line expression in python

2023-08-05 Thread Dom Grigonis
Ok.

> On 5 Aug 2023, at 16:02, Chris Angelico  wrote:
> 
> On Sat, 5 Aug 2023 at 22:49, Dom Grigonis  wrote:
>> 9. Python has a syntax for conditional expressions. Learn it, if you want to 
>> use Python. No need to create multiple syntaxes for the same thing.
>>  * Hello Chris A? :)
> 
> Nope.
> 
> ChrisA
> ___
> 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/6GDLIOAM6BBF4SNO4MVVYU64UBCPZCCQ/
> 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/JLZBOLJFDD5IVX7WY54RLRHXF4LVMK7Y/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Conditional 1-line expression in python

2023-08-05 Thread Chris Angelico
On Sat, 5 Aug 2023 at 22:49, Dom Grigonis  wrote:
> 9. Python has a syntax for conditional expressions. Learn it, if you want to 
> use Python. No need to create multiple syntaxes for the same thing.
>   * Hello Chris A? :)

Nope.

ChrisA
___
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/6GDLIOAM6BBF4SNO4MVVYU64UBCPZCCQ/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Conditional 1-line expression in python

2023-08-05 Thread Dom Grigonis
Thank you for reminding Rob.

Results are not surprising. Although 10 years ago people preferred C-style, by 
this time everyone is used to python’s expression.

By this time, after having discussions, I myself, am not a proponent of such 
change. It was more about possibility of having 2 conditional expressions, not 
changing it. It was just a part of my more general investigation. My current 
position is that “deferred evaluation” (if implemented with brief syntax) will 
cover many (sometimes seemingly unrelated) cases as a side effect of its main 
intent.

Ok, results.
Not many respondents. 48 in total. Average 24 per question. (Not sure how that 
happened.)

1. Which conditional expression is more readable?
83%: var = foo if condition else bar
17%: var = condition ? foo : bar

2. Which conditional expression is more readable?
84%: var = (foo if foo is not None else default2) if condition else (bar if bar 
is not None else default2)
16%: var = condition ? (foo is not None ? foo : default1) : (bar is not None ? 
bar: default2)

3. Would you use more conditional expression statements if it was more like in 
C?
12%: yes
88%: no

Comments:
1. They are fine the way they are.
2. They're fine for occasional use, as your second example abundantly shows, 
nested conditionals are an abomination in the sight of beasts and men.
3. The C syntax is undecipherable gobbledegook to beginners or people coming 
from other languages without that same syntax. It is the opposite of Python's 
ideal of "executable pseudocode". The Python syntax is easily understandable to 
anyone who knows English as it follows English syntax: "What are you doing 
tonight?" "I'm going to the movies, if I manage to leave work on time, 
otherwise I'll just stay home.”
  * Is the english sentence “If I manage to leave work on time, I’m going to 
the movies, otherwise, I’ll just stay home” incorrect?
4. lol, I would never use that nested conditional expression. I'd definitely 
break it out into an if-else statement that had the conditional expressions. (I 
also break out nested list comprehension a into a for loop for readability in 
the rare cases I have them.)
5. Don't change them now! (this was hashed out 20 years ago!)
  * It was more about adding an alternative, not changing it.
6. Python conditional expressions are English, or very nearly. C ones, using a 
question mark which could mean anything, are obscure (unless perhaps you are 
very very familiar with them).
7. I do not
8. they won't change
9. Python has a syntax for conditional expressions. Learn it, if you want to 
use Python. No need to create multiple syntaxes for the same thing.
  * Hello Chris A? :)
10. Conditional expressions are always confusing
11. Syntax highlighting matters and adds to the inherent readability of 
Python's ansatz.

Thank you all for taking your time in these discussions and filling in this 
quick survey. This has helped me getting answers I was looking for. Hopefully, 
this wasn’t a waste of time from your perspectives either.


—Nothing ever dies, just enters the state of deferred evaluation—
Dg

> On 5 Aug 2023, at 09:22, Rob Cliffe  wrote:
> 
> When can we expect the results of your survey?  (I responded to it.)
> Best wishes
> Rob Cliffe
> 
> On 17/07/2023 21:41, Dom Grigonis wrote:
>> 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 
>> 
>> Would be interesting to see if my preference is an outlier or not really.
>> 
>> 
>> Kind regards,
>> D. Grigonis
>> 
>> 
>> 
>> 
>> ___
>> 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/NZVLR56BFMBJXE6GN2GWRXIG6ZVAAWZZ/
>>  
>> 
>> 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