Skip to content

Conversation

@cdce8p
Copy link
Owner

@cdce8p cdce8p commented Jan 2, 2026

@cdce8p cdce8p marked this pull request as draft January 2, 2026 21:01
@Dutcho
Copy link

Dutcho commented Jan 3, 2026

In Motivation / Nested objects

  • I don’t understand what you mean by “Would for example Machine overwrite __eq__ to return False”? Should that be __bool__ perhaps?
  • The various examples are not equivalents for emails == [], which is falsey but not None; the first snippet handles that correctly, the is not None variants don’t, the try variant does (thanks to IndexError), the match does by list unpacking), but the ?. version doesn’t. For understanding I recommend consistency
  • The “IDE” remark only became clear after some thinking. Suggest rephrasing to “would be able to help with identifying potentially None valued fields

@Dutcho
Copy link

Dutcho commented Jan 3, 2026

In Motivation / Other

  • I suggest “plain sight
  • Presented pairs often aren’t exact equivalents
    • a and a.b == val: a might be a class instance with a __bool__ method returning False and val could be None
    • a and a.b and a.b.c: a could be falsey
    • d: dict | None

@picnixz
Copy link

picnixz commented Jan 4, 2026

I think this should mention what has changed since PEP-505. For instance, the rejected ideas are just copied from PEP-505. So I think you should contact past authors to ask them if you can just C/C their text.

@cdce8p
Copy link
Owner Author

cdce8p commented Jan 11, 2026

Thanks for the review @Dutcho! I've addressed your comments in 092e36f.

The various examples are not equivalents for emails == [], which is falsey but not None

That's absolutely correct and I believe something which contributed to the confusion especially regarding the ?[ ] operator. I believe in order to avoid additional confusion, it makes sense to specify that emails is either None or a list with at least one item. That way we can ignore the IndexError for now. Yes, some of the examples would either knowingly or unknowingly work for it, e.g. match, but that's not the point in the motivation section. I've added a Note block to the draft to make this clear.

Presented pairs often aren’t exact equivalents

Yes, though that is by design. Something I'd like to point out with this section is that these patterns often hide in plain sight and while not identical, using ?. or ?[ ] is actually the intended logic behind these. The None-aware access operators just make it more clear / obvious what is going to happen. I've added another Note block to point that out.

@cdce8p
Copy link
Owner Author

cdce8p commented Jan 11, 2026

I think this should mention what has changed since PEP-505. For instance, the rejected ideas are just copied from PEP-505. So I think you should contact past authors to ask them if you can just C/C their text.

Yes, some parts form the rejected ideas sections, are more or less identical to PEP 505. I've chosen to omit mentioning the original authors (e.g. in an Acknowledgements section) as he has changed his mind since writing PEP 505 so I'm not sure he'd want to be associated with a followup PEP.

His opinion if I understand it correctly, boils down to the Proliferation of None in code bases argument I listed in the Common objections section.

The link to his response regarding the status of PEP 505 at EuroPython 2022: https://youtu.be/0m2Cy5X6lcE?t=1521

@cdce8p cdce8p force-pushed the none-aware-access-operators branch from 163d0d6 to d305adf Compare January 21, 2026 19:16
@cdce8p
Copy link
Owner Author

cdce8p commented Jan 31, 2026

I've open the PR in the python/peps repo. Going to close this one now.

@cdce8p cdce8p closed this Jan 31, 2026
@cdce8p cdce8p deleted the none-aware-access-operators branch January 31, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants