Christian Theune wrote at 2008-10-16 20:27 +0200:
> ...
>Then again, verifyObject is a *very* light way to spot simple errors.
>IMHO attributes and methods aren't that different in Python, as "using"
>both may result in exceptions.

Using attributes (not computed one) does not result in exceptions.

>However, implementing a method of an interface doesn't check whether the
>method actually executes correctly -- only whether an implementation is

Of course, it does not -- because (in general) there is not a single 
call which would need to be checked but usually an unlimited number
of calls.

One may argue that a parameterless method is very similar to
an attribute (Eiffel does this), but this is not the case in Python.

>Arguably, the check for an attribute would be sufficient if it checked
>whether an attribute implementation is around -- either by a simple
>attribute value or a descriptor providing that.

Of course one can argue: Gocept argues for it and I argue against it.

>There's another method: verifyClass. This definitely only checks the
>presence of an implementation. 

It only checks methods and ignores everything else.

For methods, it uses the same "getattr" as "verifyObject" does
(in fact, both are implemented by the same function).
And if the attribute is implemented by a property (of the class, i.e.
the decriptor is on the metaclass), then the descriptors "__get__"
is called (in the same way as for "verifyObject").
Instance properties (descriptor on the class) may not define methods
(probably a bug).

Zope-Dev maillist  -
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to