Re: PEP 505 (None-aware operators) for Python 3.11

"Maarten Nieber" <[email protected]> Thu, 15 Sep 2022 16:44:30 -0000
Newsgroups gmane.comp.python.devel
Message-ID <[email protected]>
Hi Piotr, 

doesn't Doug's reply of 8:03 address this point? As he says, the none-aware operator never gives you None when you ask for a missing attribute (these cases always raise an exception). If we look at these two alternatives

phone1 = book.publisher?.owner.phone
phone2 = book.publisher.owner.phone if book.publisher else None

then they behave exactly the same. If we would misspell "owner" then in both versions we'd get the same AttributeError under the same conditions.

Best,
Maarten