On Sat, Sep 10, 2016 at 6:02 PM, David Mertz <me...@gnosis.cx> wrote:
> What I was getting at with "essentially" was that it would *do the same > thing* that an AttributeError does. That is, if `x.foo` can't be evaluated > (i.e. x doesn't have an attribute 'foo'), then access is informally "an > error." The hypothetical "x?.foo" catches that "error" and substitutes a > different value. The particular implementation under-the-hood is less > important for most programmers who might use the construct (and I think > documentation would actually give an informal equivalent as something > similar to what I put in the NoneCoalesce class). > That's not a good way to think about it. This new operator is only checking for None and not actually checking for AttributeErrors. Consider: (3).x # AttributeError {}.x # AttributeError None.x # AttributeError (3)?.x # still AttributeError {}?.x # still AttributeError None?.x # None And also: None.__class__ # <type 'NoneType'> None?.__class__ # None And it's certainly not the case that those values don't accept any attributes: (3).real # 3 {}.values # <built-in method ...> None.__class__ #<type 'NoneType'> --- Bruce Check out my puzzle book and get it free here: http://J.mp/ingToConclusionsFree (available on iOS)
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/