Re: [Python-ideas] Reduce/fold and scan with generator expressions and comprehensions

2016-11-03 Thread Stephen J. Turnbull
Danilo J. S. Bellini writes: > I'm not talking about "simple cases", but about quite general > cases, general in the sense that it allows modeling time varying > models (and the proposal is about recursion, whose computational > power should be obvious). I think I admitted that in the text yo

Re: [Python-ideas] Null coalescing operator

2016-11-03 Thread Steven D'Aprano
On Wed, Nov 02, 2016 at 10:22:56PM -0400, Kyle Lahnakoski wrote: > > On 11/2/2016 2:30 PM, Zero Piraeus wrote: > > > >If I write something like obj.attr, the failure mode I care about is that > >obj has no attribute attr, rather than that obj is specifically None (or > >one of a defined group of s

Re: [Python-ideas] Null coalescing operator

2016-11-03 Thread Paul Moore
On 3 November 2016 at 11:38, Steven D'Aprano wrote: > Looking at those examples of code, I don't think it is likely that the > majority (or even a large minority) are the result of getattr. > > But even if they are, what difference does it make? It may have mattered, if a getattr(obj, attr, coale

Re: [Python-ideas] Null coalescing operator

2016-11-03 Thread Sven R. Kunze
On 03.11.2016 02:06, MRAB wrote: On 2016-11-02 21:57, Greg Ewing wrote: MRAB wrote: target = expr1 || expr2 || expr3 target = expr1 && expr2 && expr3 except that only None would be considered falsey? Or would that be confusing? Yes, I think that borrowing an operator from C but givi

Re: [Python-ideas] Null coalescing operator

2016-11-03 Thread Chris Barker
Thanks Steven, this is great! so -- when all this started, I think one of the use cases was to clean up this really common idiom: self.an_arg = the_default if an_arg is None else an_arg so would that be: self.an_arg = the_default ?? an_arg That would be nice. Though the fact that I'm still no

Re: [Python-ideas] Null coalescing operator

2016-11-03 Thread MRAB
On 2016-11-03 18:36, Chris Barker wrote: Thanks Steven, this is great! so -- when all this started, I think one of the use cases was to clean up this really common idiom: self.an_arg = the_default if an_arg is None else an_arg so would that be: self.an_arg = the_default ?? an_arg That would

Re: [Python-ideas] Null coalescing operator

2016-11-03 Thread Chris Barker
On Thu, Nov 3, 2016 at 12:00 PM, MRAB wrote: > self.an_arg = the_default if an_arg is None else an_arg > > > No, ?? is a bit like 'or', except that only None is falsey, so it would be: >> > > self.an_arg = an_arg ?? the_default thanks! and actually, that reads much better to me. -CHB --

[Python-ideas] Going off-topic (was: Null coalescing operator)

2016-11-03 Thread Brett Cannon
On Wed, 2 Nov 2016 at 17:34 Mikhail V wrote: > On 2 November 2016 at 21:50, David Mertz wrote: > > Even though I really don't want new null-coalescing operators, I really > > appreciate the ternary operator in Python (or in C). > > > > On Wed, Nov 2, 2016 at 12:38 PM, Mikhail V wrote: > >> > >>

Re: [Python-ideas] Null coalescing operator

2016-11-03 Thread Steven D'Aprano
On Thu, Nov 03, 2016 at 12:35:07PM -0700, Chris Barker wrote: > On Thu, Nov 3, 2016 at 12:00 PM, MRAB wrote: > > > self.an_arg = the_default if an_arg is None else an_arg > > > No, ?? is a bit like 'or', except that only None is falsey, so it would be: > > > > self.an_arg = an_arg ?? the_def

Re: [Python-ideas] Null coalescing operator

2016-11-03 Thread Chris Barker
On Thu, Nov 3, 2016 at 4:06 PM, Steven D'Aprano wrote: > > > No, ?? is a bit like 'or', except that only None is falsey, so it > would be: > > > > > > self.an_arg = an_arg ?? the_default > > > > > > thanks! and actually, that reads much better to me. > > That suggests a possible different col