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
3
u/k0pernikus Jul 13 '26
Python always has been very opinionated. (I don't agree with all of its choices. I HATE the for-else and try-else syntax.) Yet appeal to other languages only gets you so far, or you could make the case that python should adopt semicolon at the end of the line and braces around function blocks.
I have worked with many datastructures, and the things have caused me the most pain: random nullables, unexpected implicit type conversations, and unexpected mutabality (just recently had to deal with an API that served uniquid as KEYS).
And I strongly disagree with the notions of being unable to not being able to express your objects as clean variants.
I don't control external data structures, but I do very much control how I parse them, and the datastructures they map into. That IS my job a a developer.
That part is even easy, more so with agentic tooling doing most of the writeup for me. Basically, I can create my own strictly-typed oasis in the desert of crap. Or in your analogy: You can walk on roofs. Depending on the building's height you have different needs for safeguards. If you stumble off your bikeshed, you may break a leg. If you stumble off a skycraper, you are very much dead.
Hence, the tools we use should depend on the building we climb. The more complex your product becomes, the more you will try to erdicate any occurence of nullable types in your codease. I will die on that hill.