[Python-ideas] PEP 505: None-aware operators

Kyle Lahnakoski klahnakoski at mozilla.com
Thu Jul 26 10:58:53 EDT 2018


On 2018-07-25 23:53, David Mertz wrote:
> On Wed, Jul 25, 2018, 11:27 PM Chris Angelico <rosuav at gmail.com
> <mailto:rosuav at gmail.com>> wrote:
>
>
>     means that you cannot do this:
>
>     >>> NullCoalesce(spam).nil is None
>
>     This IS fundamentally unfixable in a library.
>
>
> Right now, you can still always call .unbox() at the end to get the
> underlying value. I agree that's a little ugly, hence why I added the
> wrapt proxy stuff. Most operations trigger unboxing, but indeed not
> simply echoing to the shell.
>

Chris is correct to point out this problem with comparing to None. I
have that problem with my own version of the proxy library, similar to
what David is building:  I use the proxy  heavily; to the point where
almost any line may be touching a proxy rather than a real value. To
avoid bugs, I disallow "is None" comparisons, mandating "== None" instead. 

Using unbox() is an alternative,  but it is uglier than than swapping
"as" for "==".


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180726/2b5e686e/attachment.html>


More information about the Python-ideas mailing list