Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80564 > unrolled thread

Re: I love assert

Started byAlbert-Jan Roskam <fomcl@yahoo.com>
First post2014-11-11 21:09 +0000
Last post2014-11-11 21:09 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: I love assert Albert-Jan Roskam <fomcl@yahoo.com> - 2014-11-11 21:09 +0000

#80564 — Re: I love assert

FromAlbert-Jan Roskam <fomcl@yahoo.com>
Date2014-11-11 21:09 +0000
SubjectRe: I love assert
Message-ID<mailman.15692.1415740487.18130.python-list@python.org>

----- Original Message -----

> From: Ethan Furman <ethan@stoneleaf.us>
> To: python-list@python.org
> Cc: 
> Sent: Tuesday, November 11, 2014 9:08 PM
> Subject: Re: I love assert
> 
> On 11/11/2014 11:40 AM, Peter Cacioppi wrote:
>> 
>>  I get the impression that most Pythonistas aren't as habituated with 
> assert statements
>>   as I am. Is that just a misimpression on my part? If not, is there a good 
> reason to
>>   assert less with Python than other languages?
>> 
>>  As far as I can tell, Python supports assert perfectly well. When run with 
> the optimization
>>   flagging, the asserts are truly removed.
>> 
>>  I think one needs to take care with some basic assert coding - it's not 
> a substitute for
>>   unit tests, it doesn't absolve you of normal exception 
> responsibilities, and, most of all,
>>   it should be used for passive inspection and not action. But given these 
> guidelines, I
>>   still find it very useful as "active comments".
> 
> asserts are a specialized tool, easily abused.  Sounds like you are using them 
> exactly as intended.


Would you say that assert is baaadly abused in nose?*) I never tried it, but probably all tests pass when Python is run with -O or -OO.

*) Actually, I love that package. Much cleaner than unittest.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web