27 May
2005
27 May
'05
1:19 p.m.
[Tres Seaver] [...]
- -1. Python's 'hasattr' semantics are *broken by definition*, and will never be fixed (because of backward compatibility). Non-Zope Python programmers will *not* expect or want exceptions raised from 'hasattr'.
As a local patch, this isn't too bad (one could even package it as a do-nothing-after-initialization product). However, no redistributed product code should rely on the presence of a patched 'hasattr', but should use the 3 argument getattr instead.
OTOH, defining & importing a utility function-- say, safehasattr() --would make it all explicit. That's what ZODB does. I certainly agree that changing the behavior of a builtin function by magic is at best highly dubious practice.