[Zope-dev] Re: hasattr implementation for Zope?

Tim Peters tim.peters at gmail.com
Fri May 27 09:19:19 EDT 2005


[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.


More information about the Zope-Dev mailing list