On Fri, May 27, 2005 at 11:49:03AM -0400, Jim Fulton wrote:
> BTW, I prefer to code things like this in the following way:
> def safe_hasattr():
> marker = object()
> def safe_hasattr(obj, attr):
> return getattr(obj, attr, marker) is not marker
> return safe_hasattr
> safe_hasattr = safe_hasattr()
> This way, there aren't any extra arguments or funny
> globals to confuse matters. (I've seen code that broke
> because people tried to reuse marker definitions accross
Interesting hack. It gets rid of the extra arguments and globals
all right, but it also makes the source a bit less obvious to read.
Does this play nicely with documentation extraction?
AFAICS the docstring must be given on the inner function definition.
Zope-Dev maillist - Zope-Dev@zope.org
** No cross posts or HTML encoding! **
(Related lists -