kislyuk / ensure

Validate conditions, Python style.

Home Page:https://kislyuk.github.io/ensure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Return boolean values?

opened this issue · comments

Hey, I've been using ensure as contracts for functions, but it's pretty tricky due to the varying nature of return values. Can we have an option in the Ensure constructor to return a simple boolean True/False value? Or, and I think this is a much better solution because it allows for chaining, simply implement __bool__ for all values returned by predicates to return the actual pass/fail status.

Implementing __bool__ seems like a good idea. I won't have time for this until next week at the earliest. Would you like to take a stab at it?

@kislyuk See #23. This is a pretty simple change.