When to use assert

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Nov 17 19:52:37 EST 2013


On Sun, 17 Nov 2013 06:50:56 -0600, Tim Chase wrote:

> On 2013-11-17 07:35, Steven D'Aprano wrote:
>> py> x = 23
>> py> assert x > 0, "x is not zero or negative"
> 
> This is the worst way to use an assertion:  with a misleading message
> ;-)


D'oh!


Sorry about that.



-- 
Steven



More information about the Python-list mailing list