Re:Contract based programming (Python)
by MostAwesomeDude on Monday July 04, 2011 @01:51AM
(#2725533)
Ah, I see. You should definitely check out zope.interface; it's a different approach to a similar problem. This is quite cool, though. Good work!
The current validators throw Exception by default. They can be optionally take an `error_handler` to which they pass the errors. Bringing in inside the function will mean manually accumulating the errors from various validators.
Also, these validators are mostly for conditions which must be met. Say you are writing a sqrt function, then the pre-condition is the number shouldn't be negative and that isn't something that can be turned off.
I don't know how zope.interface works but this isn't supposed to be optional validation. It is basically about taking the manual checks from inside the function to above the function with convenient declarative syntax.