[Python-ideas] PEP 505 (None coalescing operators) thoughts

Ron Adam ron3200 at gmail.com
Sun Oct 4 03:58:19 CEST 2015


On 10/03/2015 05:59 PM, Andrew Barnert via Python-ideas wrote:


> Meanwhile, you still haven't answered what "return the arguments"
> should actually mean, given that in Python, "the arguments" are a
> tuple of positional arguments plus a dict of keyword arguments.

The simplest example is if a function has 5 arguments, then it will 
return those in the order they are in the signature.

 >>> def foo(a, b, c, x=1, y=2):
...     return a, b, c, x, y

 >>> (a, b, c, x, y) = foo(1, 2, 3, 4, 5)
 >>> a, b, c, x, y
(1, 2, 3, 4, 5)

 >>> a = foo(1, 2, 3, 4, 5)
 >>> a
(1, 2, 3, 4, 5)

But I think that may not be as useful as I was thinking.  Only a few 
functions return the same number of arguments as they take.

It would actually be more applicable to filters, where a function is 
applied to each item, and None might be the default to do nothing with 
that item.


>>> This whole line of discussion started out as a very tenuous
>>> suggestion/possibility.  I even said it was going out on a limb,
>>> so I really wasn't expecting to defend it as if it was a
>>> complete idea.
>>>
>>> The concept I am thing of is doable, but not in the way I was
>>> thinking at first, but I also think it doesn't fit with python
>>> very well.

> I think either it isn't doable, or it fits into Python even more
> poorly than you think. But I'm just one guy, who could easily be
> wrong. If you think otherwise, I would be interested in seeing what
> you can come up with. Even if it ends up not being a proposal you'd
> want to back, it would probably give insights to half the people
> involved in the larger discussion on null coalescing and null
> conditionals. And if it turns out that I'm right and you can't make
> it work, convincing yourself of that might lead to useful insights
> into the larger discussion that you could share here. After all, it
> seems like we're kind of stuck on conflicting incomplete intuitions
> here, and just arguing those back and forth isn't getting us very
> far.

That's exactly what we are doing. ;-)

I doubt I can do better than what's already suggested at this point.

Cheers,
    Ron

























More information about the Python-ideas mailing list