Clarity vs. code reuse/generality

Paul Rubin http
Sat Jul 4 22:55:04 CEST 2009


Scott David Daniels <Scott.Daniels at Acm.Org> writes:
> And I curse such uses, since I don't get to see the troublesome value,
> or why it is troublesome.  In the above case, y = sqrt(x) at least
> raises ValueError('math domain error'), which is more information than
> you are providing.
>
> How about:
>       if x >= 0: raise ValueError('x = %r not allowed (negative)?' % x)

Better still in these situations is to throw to pdb.
But yes, you can put a formatted string in a check message.



More information about the Python-list mailing list