r/Python • • 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

192 comments sorted by

View all comments

Show parent comment

2

u/sausix Jul 13 '26

Python has a lot of syntax and semi syntax features already compared to other languages. New features get added very late and after a lot of discussion. Remember the match/case feature? That's quite powerful and I rarely see it in today's code.

I think there is not yet enough demand for this even it's just another symbol for the syntax rules.

As I said you can create a lot of features today without changing the syntax.

So if someone decided to chain a lot of function calls without violating another best practice then just wrap it in a helper class to allow nullable function chaining.