Re: [Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

2018-02-16 Thread Chris Barker - NOAA Federal
Sent from my iPhone > A thought just occurred to me. Maybe we should just add a Boolean class to > numbers? This makes lots of sense to me. Bool is a subclass of int — might as well embrace that fact. -CHB ___ Python-ideas mailing list

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] Temporary variables in comprehensions

2018-02-16 Thread Martin Teichmann
Hi list, > But when it comes to something like > [f(x) + g(f(x)) for x in range(10)] > you find you have to sacrifice some readableness if you don't want two f(x) > which might slow down your code. > > Someone may argue that one can write > [y + g(y) for y in [f(x) for x in range(10)]]

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