[Python-ideas] PEP 505: None-aware operators
Nicholas Cole
nicholas.cole at gmail.com
Mon Jul 23 02:23:31 EDT 2018
On Mon, Jul 23, 2018 at 2:38 AM Steven D'Aprano <steve at pearwood.info> wrote:
>
> On Mon, Jul 23, 2018 at 12:59:20AM +0200, Giampaolo Rodola' wrote:
>
> > You're back at "since we have X that justifies the addition of Y" [1]
> > and AFAICT that's the only argument you have provided so far in a 100+
> > messages discussion.
>
> The PEP itself justifies the addition of Y.
This thread seems to be unnecessarily heated.
Other languages have these operators, and so they aren't a wild idea.
That said, from what I've seen, Swift optionals are very different
things, and Python really has nothing like them.
In Python, is None really special enough to need an operator like this?
One issue for me is that the trivial case is already a one-liner:
if a is None: a = 10
And it works for other things too:
if a is -1: a = 10
if not a: a = 10
Again, is None special enough in Python to need this operator? I don't know.
And that leads to a simple question: how many times does this actually
occur in real-world by python code? -- i.e. how many times do I want
to check the value of an existing label, and, finding it is None (and
None specifically), then assign it a value?
What does a scan through the existing core library say?
I'm +0 on this proposal.
Best wishes,
N
More information about the Python-ideas
mailing list