Re: [Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-19 Thread David Foster
(1) This proposal serves well to eliminate repeated computations by allowing what is an inline assignment to a temporary variable. But it doesn't seem to make the case of None-aware operators any less verbose than they would be otherwise. Proposal: value = ?it.strip()[4:].upper() if

Re: [Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-19 Thread Ethan Furman
On 02/18/2018 05:57 PM, Nick Coghlan wrote: On 17 February 2018 at 02:31, Ethan Furman wrote: On 02/15/2018 11:55 PM, Nick Coghlan wrote: However, while I think that looks nicer in general, we'd still have to choose between two surprising behaviours: * implicitly delete the statement locals

Re: [Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-18 Thread Nick Coghlan
On 17 February 2018 at 02:31, Ethan Furman wrote: > On 02/15/2018 11:55 PM, Nick Coghlan wrote: >> However, while I think that looks nicer in general, we'd still have to >> choose between two surprising behaviours: >> >> * implicitly delete the statement locals after the

Re: [Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-16 Thread Ethan Furman
On 02/15/2018 11:55 PM, Nick Coghlan wrote: On 16 February 2018 at 12:19, rym...@gmail.com wrote: I don't know...to me this looks downright ugly and an awkward special case. It feels like it combines reading difficulty of inline assignment with the awkwardness of a magic word and the ugliness

Re: [Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-16 Thread Rhodri James
On 16/02/18 02:06, Nick Coghlan wrote: The recent thread on variable assignment in comprehensions has prompted me to finally share https://gist.github.com/ncoghlan/a1b0482fc1ee3c3a11fc7ae64833a315 with a wider audience (see the comments there for some notes on iterations I've already been

Re: [Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-16 Thread Nick Coghlan
On 16 February 2018 at 18:36, Kirill Balunov wrote: > What about (| val = get_value(x) |) assignment expression which will be True > if success, and None if not? > > So it will be value = f() if (| f = calculate |) else default…The idea is > inspired from C’s assignment,

Re: [Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-16 Thread Kirill Balunov
What about (| val = get_value(x) |) assignment expression which will be True if success, and None if not? So it will be value = f() if (| f = calculate |) else default…The idea is inspired from C’s assignment, but needs some special treatment for anything which is False in boolean context. With

Re: [Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-15 Thread Nick Coghlan
On 16 February 2018 at 12:19, rym...@gmail.com wrote: > I don't know...to me this looks downright ugly and an awkward special case. > It feels like it combines reading difficulty of inline assignment with the > awkwardness of a magic word and the ugliness of using ?. Basically,

Re: [Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-15 Thread rym...@gmail.com
I don't know...to me this looks downright ugly and an awkward special case. It feels like it combines reading difficulty of inline assignment with the awkwardness of a magic word and the ugliness of using ?. Basically, every con of the other proposals combined... -- Ryan (ライアン) Yoko Shimomura,

[Python-ideas] Coming up with an alternative to PEP 505's None-aware operators

2018-02-15 Thread Nick Coghlan
The recent thread on variable assignment in comprehensions has prompted me to finally share https://gist.github.com/ncoghlan/a1b0482fc1ee3c3a11fc7ae64833a315 with a wider audience (see the comments there for some notes on iterations I've already been through on the idea). == The general idea ==