r/Python • u/philtrondaboss • Jul 12 '26
Discussion Will PEP 505 ever be accepted?
https://peps.python.org/pep-0505/
I don't understand how null safe operators are less like plain English than other implemented features like the walrus operator.
In my opinion, the member access operator would make python significantly easier to read and understand.
Here's an example:
f = foo()
if f is None:
baz = ""
else:
baz = f.bar()
baz = foo()?.bar() ?: ""
EDIT: I forgot that "and" and "or" can be sometimes used in place of "?." and "?:" if the left value is not False, '', 0, [], or {}. It's a very implicit null check and has a lot of unexpected behavior.
17
Upvotes
View all comments
Show parent comment
13
u/Technical_Income4722 Jul 13 '26
Nah this is gross (imo of course, to each his own ultimately).
Symbols that rely on familiarity are always gonna reduce readability and add confusion, it's just how it goes. Same reason ternary operators are often discouraged in C code. I'm also admittedly biased against question marks in code because they only indicate that there's a question, not always what the question is.
Your pythonic example and others (like below) look just fine to me because you can actually reason out what's going on without having to know an obscure Python operator.
Symbolic representations of things are way worse if the dev has anything less than great familiarity, which defeats the purpose. It saves some space, sure, but I'd argue it does not increase readability.