Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.043 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'expectation': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; '~ethan~': 0.09; 'executed,': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'example': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply- To:1': 0.27; 'code': 0.31; 'apparently': 0.31; "i'd": 0.34; 'something': 0.35; 'but': 0.35; 'shows': 0.36; 'being': 0.38; 'somebody': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'that,': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'ian': 0.60; 'received:173': 0.61; 'more': 0.64; 'optimized': 0.68; 'honest': 0.78; 'refuse': 0.93 Date: Wed, 12 Nov 2014 14:56:46 -0800 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: I love assert References: <96c138e4-ab95-4e5f-a0c8-e696b5a926bb@googlegroups.com> <87a93wqeq3.fsf@elektro.pacujo.net> <87y4rgozgd.fsf@elektro.pacujo.net> <87lhngox30.fsf@elektro.pacujo.net> In-Reply-To: <87lhngox30.fsf@elektro.pacujo.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415833010 news.xs4all.nl 2963 [2001:888:2000:d::a6]:54549 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80651 On 11/12/2014 02:47 PM, Marko Rauhamaa wrote: > Ian Kelly : > >> Although to be honest I'd rather use something like "raise >> RuntimeError('Unreachable code reached')" than "assert False" here. If >> the expectation is that the code will never be executed, then there's >> no reason to ever optimize it out. > > Asserts have nothing to do with them being optimized out. Asserts are > communication. Asserts are code that can stop your program. That's a bit more than just communication. And your example of how you use asserts shows a bad way to use them, which has been explained. Apparently you refuse to learn from that, but hopefully somebody else will. -- ~Ethan~