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
4
u/Due_Campaign_9765 Jul 13 '26
Python is a fully fledged programming language you can do implement anything you'd like in it, including weird DSLs expressed as text. Obviously
Should you do that or rather introduce a feature that's not really controversial, problematic and existed for decades in other programming languages that simplifies traversing the object graph which is like 50% of modern development? Probably not.
Also saying that nested nullable values is somehow a bad datastructure is ridicilous.
You can't always express your objects as clean variants, there will always be weird business logic exception, rushed/time constraints and other things that makes a couple of levels of nullable values only realistic outcome.
It's like saying that you shouldn't be afraid of walking on roofs because gravitiy shouldn't kill people. Yeah probably. Gravity also just "is"