[Python-ideas] PEP 505: None-aware operators

Paul Moore p.f.moore at gmail.com
Sun Jul 22 06:26:22 EDT 2018


On 22 July 2018 at 11:13, Giampaolo Rodola' <g.rodola at gmail.com> wrote:
> - "a?[2] ?? 3" means "index 2 of list a is picked up if a is not None, else
> use 3"

Actually, doesn't it mean

if a is not None, pick up index 2 of the list.
If a is None, OR IF a[2] IS NONE, then use 3.
If a is None but a[2] is not None, use a[2].

?

Which is subtly different, and probably at least as prone to
"accidental" errors as some of the constructs the None-aware operators
are intended to replace.

Paul


More information about the Python-ideas mailing list