Op wo 1 aug. 2018 11:10 schreef Jonathan Fine <jfine2358@gmail.com>:


You're right to be cautious. My understanding of PEP 505 is that
#13.  a ?. b ?. __str__
#14. (a ?. b) ?. __str__
are not equivalent. The first is None, and the other is None.__str__.
That looks like a gotcha.


No.
None.?__str__
produces None, even though None has a __str__ attribute.

I am pretty sure 
a?.b?.c == (a?.b)?.c

and more generically

chain_A ?. chain_B == (chain_A) ?. chain_B

Stephan


(By the way, it was not my intention to catch you out. I'm simply
looking for clarity. I wasn't aware of the gotcha until I started
answering myself the question I had asked you.)

However, the None object is somewhat special, in that all it's methods
and double-under (dunder) methods. And one of them is __bool__.  And
we can't add or change the attributes of None.

Chris, you don't have to reply to this. But I would be pleased if an
expert could either tell me that my neck is safe, or produce a value
of 'a' that cuts it off (so to speak).

--
Jonathan
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/