Re: [Python-ideas] Leave off "else" in ternary expression

2016-10-28 Thread Sjoerd Job Postmus
On Fri, Oct 28, 2016 at 11:28:16AM -0400, Todd wrote: > The null-coalescing discussion made me think about the current ternary "x = > a if b else c" expression. In normal "if / else" clauses, the "else" is > optional. I propose doing the same thing with ternary expressions > (although I don't

Re: [Python-ideas] Leave off "else" in ternary expression

2016-10-28 Thread Todd
That is a good point. Nevermind then. On Fri, Oct 28, 2016 at 12:20 PM, David Mertz wrote: > This seems pretty nonsensical to me. Ternaries are not only used in simple > assignments. > > E.g. 'myfunc(a, b if pred else c, d)' is common and obvious. > > 'myfunc(a, b if pred,

Re: [Python-ideas] Leave off "else" in ternary expression

2016-10-28 Thread David Mertz
This seems pretty nonsensical to me. Ternaries are not only used in simple assignments. E.g. 'myfunc(a, b if pred else c, d)' is common and obvious. 'myfunc(a, b if pred, d)' is strange with no obvious semantics. On Oct 28, 2016 11:29 AM, "Todd" wrote: > The

Re: [Python-ideas] Leave off "else" in ternary expression

2016-10-28 Thread Todd
On Fri, Oct 28, 2016 at 11:36 AM, Bernardo Sulzbach < mafagafogiga...@gmail.com> wrote: > On 10/28/2016 01:28 PM, Todd wrote: > >> >> The idea would be to allow this syntax: >> >> x = a if b >> >> Which would be equivalent to: >> >> x = a if b else x >> >> > What if x has not been defined yet? >

Re: [Python-ideas] Leave off "else" in ternary expression

2016-10-28 Thread Bernardo Sulzbach
On 10/28/2016 01:28 PM, Todd wrote: The idea would be to allow this syntax: x = a if b Which would be equivalent to: x = a if b else x What if x has not been defined yet? -- Bernardo Sulzbach http://www.mafagafogigante.org/ mafagafogiga...@gmail.com