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

5

u/Mihikle Jul 13 '26

Been a professional developer 10+ years. Never had to structure code like you suggest.

I don’t think you really understand single responsibility. “Do one conceptual thing” isn’t exclusive to classes and modules by any stretch

-1

u/Due_Campaign_9765 Jul 13 '26

I think you're lying. Or not using a type checker so you're not even aware. But that doesn't matter, i'm happy you supposedly never had to access multilevel nullable values. Most people do daily.

Also the SRP doesn't state you what you just stated, you could have at least reread it before doubling down. There isn't anything that "changes" in operators, so it can't coherently apply here.

Not to mention all of those solid principles are quite crap generalization that can't ever be applied universally or near-universally and thus they're useless.

2

u/Mihikle Jul 13 '26

Sure man whatever you say.

You couldn’t possibly read a guideline like SRP, take the core principle and apply it to something like function design, that would be impossible of course.