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.
14
Upvotes
View all comments
Show parent comment
3
u/the_dimonade Jul 14 '26
I agree... I work with a large python codebase and I doubt that there is a single walrus in there, and even if there is, it could be rewritten with more clarity without it.
All the examples of the use cases I've seen look convoluted to begin with and not realistic at all... it feels like a solution looking for a problem at this point.
Also in multilingual codebases devs from other languages would prefer to not use an unfamiliar esoteric operator. I have more than 10 years of software and python experience, and never have though "walrus would be good here". Maybe it is a domain operator? I don't know.
Weak type hints is also a reason to avoid it.