On 8-3-2014 1:15, Dan Stromberg wrote:
> On Fri, Mar 7, 2014 at 3:11 AM, Steven D'Aprano
> <steve+comp.lang.pyt...@pearwood.info> wrote:
> 
>>
>> Assertions are not bad! They're just misunderstood and abused.
> 
>> You should read this guy's blog post on when to use assert:
>>
>> http://import-that.dreamwidth.org/676.html
> 
> Nice article.
> 
> BTW, what about:
> 
> if value >= 3:
>    raise AssertionError('value must be >= 3')
> 
> ?

I don't think this qualifies as an assertion. Also, because AssertionError is 
documented
as "Raised when an assert statement fails", I would never use it myself 
explicitly like
this.

You should use ValueError instead (or a more precise exception such as 
IndexError, if
appropriate).

Irmen




-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to