[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-18 Thread Chris Angelico
On Wed, 19 Jul 2023 at 11:51, Dom Grigonis wrote: > > Coming back to deferred evaluation, > > https://peps.python.org/pep-0671/ > These 2 aren’t really orthogonal in functionality. Maybe in implementation. > But PEP671 is a certain subset of deferred evaluation as it can achieve the > same with 1

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-18 Thread Dom Grigonis
Coming back to deferred evaluation, https://peps.python.org/pep-0671/ These 2 aren’t really orthogonal in functionality. Maybe in implementation. But PEP671 is a certain subset of deferred evaluation as it can achieve the same with 1 extra line at the start of

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-18 Thread Richard Damon
On 7/18/23 12:03 AM, Dom Grigonis wrote: Ok, thanks. I think what I am aiming at is that there is a pool of suggestions and PEPs that are pointing towards very similar direction and I find myself often wandering in the same space, just trying to figure out what it exactly is. It sometimes fee

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-18 Thread Chris Angelico
On Tue, 18 Jul 2023 at 19:02, Dom Grigonis wrote: > > Thank you. > > I meant “superset of 671, not 505”… > > One question: > > def bar(a => None); > return foo(a) > > def foo(a => object()): > return a > > How would I force foo’s default from bar’s call? That's a known-hard problem. The b

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-18 Thread Dom Grigonis
Thank you. I meant “superset of 671, not 505”… One question: def bar(a => None); return foo(a) def foo(a => object()): return a How would I force foo’s default from bar’s call? Would something like this work? def foo(a => object() if a is None else a): return a > On 18 Jul 2023, a

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 16:25, Dom Grigonis wrote: > > Yes, thank you, this would definitely be nice to have. > > Although, "A generic system for deferred evaluation has been proposed at > times“ sound better if it was a superset of PEP505. Could you refer me to any > resources about such conside

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Dom Grigonis
Yes, thank you, this would definitely be nice to have. Although, "A generic system for deferred evaluation has been proposed at times“ sound better if it was a superset of PEP505. Could you refer me to any resources about such considered system? > On 18 Jul 2023, at 08:33, Chris Angelico wrote

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 14:07, Dom Grigonis wrote: > PEP505 would solve this nicely, but it only applies to None and would not > apply to say user-defined sentinels and many other cases where permutations > of different conditionals arise. > PEP 671 would solve this nicely too. ChrisA _

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Dom Grigonis
Ok, thanks. I think what I am aiming at is that there is a pool of suggestions and PEPs that are pointing towards very similar direction and I find myself often wandering in the same space, just trying to figure out what it exactly is. It sometimes feels more verbose than it could be for what it

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Greg Ewing
On 18/07/23 10:30 am, Dom Grigonis wrote: Although, the argument that python is meant to be read as english is very much valid, but I do not see why it has to be an overarching one if the opportunity cost of it is too great in other dimensions. It's not overarching. Many things in Python don't

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Dom Grigonis
Much of what you respond to me indicates that you did not properly read what I have written and did not really understand where I am coming from. > On 18 Jul 2023, at 04:04, Chris Angelico wrote: > > On Tue, 18 Jul 2023 at 10:37, Dom Grigonis wrote: >> As opposed to >> >> if a == 0: >> foo,

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 10:37, Dom Grigonis wrote: > As opposed to > > if a == 0: >foo, bar = var1, variable2 > else: >foo, bar = default, default2 > > > Again, one is `a == 0`, another is `b == 0`. I didn’t do a good job conveying > this did I… Will try to be more precise and leave less r

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Dom Grigonis
>> # Code becomes easily read when there is a nice alignment in horizontal >> space. e.g.: >> >> variable = None >> length_1 = None >> somethin = None >> > > variable = length_1 = somethin = None Obviously they would not all be None, just chosen None as `any dummy value`, mistake on my part

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 08:34, Dom Grigonis wrote: > > I still feel that compared to list comprehension and other functional and > elegant python constructs, python's if-else expression is lacking. I often > choose to go multi-line much more verbose code as opposed to more brief > constructs jus

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Dom Grigonis
Ah, I can’t do that post-publish. This will have to suffice for now. If this got to a point where there was a case to revise 2005 decision or introduce an alternative (which I very much doubt can happen any time soon), much more elaborate research and survey would have to be done and all options

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Laurent Lyaudet
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