2 ms·
These have existing exactly the same in C# for a bit, and they’re fantastic bits of sugar — null checking comes up everywhere so its a low-impact high-volume be
by setr 5y ago
These have existing exactly the same in C# for a bit, and they’re fantastic bits of sugar — null checking comes up everywhere so its a low-impact high-volume benefit; looking at it as a one-off is pointless (see fstrings as a similar change)
> mangle_from_ = policy?.mangle_from_ ?? True
This scenario is the largest gain — nested nullable references is a massive pain, especially when you go deeper. It’s trivially superior to nested ternary or if statements.
IMO the benefits easily make it a worthwhile sugar to add — the only concern is whether it fits the python “aesthetic”; which to me is a flat no, but at the same time it seems like the walrus operator will be the defining moment of that aesthetic era coming to an end