[Python-ideas] A better (simpler) approach to PEP 505

Grégory Lielens gregory.lielens at gmail.com
Mon Jul 23 12:37:36 EDT 2018


Your wrapper class can also, I think:
 Swallow exceptions, especially AttributeError
 Specify the sentinel, if it is not None
 Work for getitem 

Mixing is indeed more difficult, and there is probably performance impact.
Still, it's general and does not need to touch the implementation of the class you want to descend...

I like it better than the operators

Another idea, may be stupid, maybe not: what if None fails with a subinstance of AttributeError, and a subinstance of KeyError, or IndexError. Then a try/except catching only those exceptions would also work quite nicely...


More information about the Python-ideas mailing list