Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'false,': 0.07; 'raises': 0.07; 'exception,': 0.09; 'reached.': 0.09; '-q,': 0.16; '24,': 0.16; 'chained': 0.16; 'curious.': 0.16; 'ifs': 0.16; 'reraise': 0.16; 'sees': 0.16; 'subject:expressions': 0.16; 'wrote:': 0.17; 'code.': 0.20; 'programming': 0.23; 'errors': 0.23; 'statement': 0.23; "i've": 0.23; 'header:In-Reply-To:1': 0.25; 'implemented': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'assert': 0.29; 'context,': 0.29; "i'm": 0.29; 'problem.': 0.32; 'to:addr:python-list': 0.33; 'point.': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'really': 0.36; 'tool': 0.36; 'but': 0.36; 'anything': 0.36; 'execute': 0.37; 'option': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'skip:u 10': 0.60; 'matter': 0.61; 'more': 0.63; 'here': 0.65; 'jul': 0.65; 'to:name:python': 0.84; 'preventing': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=JH7e8f+P1dHmuywN7SDnFD57Z6NQ4Q+kfR2+8QOiH1M=; b=rjMTK2Vj+Z/3v+m3CMcdjk0oE+VUcekfcCBIY46A2lal7EPOm4tSV2GSnJpmmVQG1k Gyks44D3gWjhIGWC0jj9Qb82OAeCSSMj9Xh526BxsjPszWrY/4imNqMpBb/gUQDrXGVb 2m0jK/hJoqOgvJgIbI2qkkvDwbl6XKp2Dmo3ME/MmpM2M5OimRsq4XPcdoDxn/UhK61M IhNZ3PTulUrCScLqGrG1pI7FmZk5p7LjfH8Nb1ksRc/rp2v5vy76YDpoMoFinNIoby/y 3xztigwxeBqS0wqZ6m9i6t4cwnth8DfLI5v+SMbMe1gma799sBvCeP5QMO0BbRyItZ7j lSYQ== MIME-Version: 1.0 In-Reply-To: <8c5da998-e428-4000-adba-f5eee86ac971@d32g2000yqn.googlegroups.com> References: <9f6bed70-1ec1-4e3e-bdd0-c96013bf7df2@googlegroups.com> <8c5da998-e428-4000-adba-f5eee86ac971@d32g2000yqn.googlegroups.com> From: Ian Kelly Date: Tue, 24 Jul 2012 15:22:48 -0600 Subject: Re: assert expressions To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1343165006 news.xs4all.nl 6874 [2001:888:2000:d::a6]:43549 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26013 On Tue, Jul 24, 2012 at 2:44 PM, Wanderer wrote: > I'm using getopt but not at that point. I really don't have a problem. > I'm just curious. I've never seen anything else after > assert False, > > Here is some code. It doesn't matter what you put after the assert False, because that line is not actually reached. When getopt sees the -q, it immediately raises a getopt.error, which you catch and then immediately reraise as a Usage exception, which is then caught and printed at the end. The chained ifs with the assert statement never even execute in this scenario. Seeing the assert in context, it makes more sense. It's not intercepting some unimplemented option and preventing the program from proceeding; it's there as a development tool to catch programming errors where an option is added to the getopt configuration but is not implemented in the if chain.