Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'url:pipermail': 0.05; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'statements': 0.09; 'tests,': 0.09; 'python': 0.11; 'language.': 0.14; 'pythonistas': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'substitute': 0.16; 'exception': 0.16; 'language': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'not,': 0.20; 'coding': 0.22; 'header:User- Agent:1': 0.23; "aren't": 0.24; 'removed.': 0.24; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'assert': 0.31; 'critical': 0.32; 'run': 0.32; 'url:python': 0.33; 'basic': 0.35; 'but': 0.35; 'there': 0.35; 'impression': 0.36; 'useful': 0.36; 'url:org': 0.36; 'should': 0.36; 'unit': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'url:mail': 0.40; 'truly': 0.60; 'most': 0.60; 'our': 0.64; 'charset:windows-1252': 0.65; '"active': 0.84; 'action.': 0.84; 'received:2': 0.84; 'am.': 0.91; 'passive': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: I love assert Date: Tue, 11 Nov 2014 20:34:01 +0000 References: <96c138e4-ab95-4e5f-a0c8-e696b5a926bb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-2-98-204-224.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <96c138e4-ab95-4e5f-a0c8-e696b5a926bb@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415738058 news.xs4all.nl 2922 [2001:888:2000:d::a6]:59262 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80560 On 11/11/2014 19:40, 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". > Please check this out https://mail.python.org/pipermail/python-list/2013-November/660401.html as it was released to critical acclaim :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence