Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: I love assert Date: Wed, 12 Nov 2014 23:56:18 +0200 Organization: A noiseless patient Spider Lines: 24 Message-ID: <87y4rgozgd.fsf@elektro.pacujo.net> References: <96c138e4-ab95-4e5f-a0c8-e696b5a926bb@googlegroups.com> <87a93wqeq3.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="32342"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+ctdYIxyAfYEf+Yy+3q8b" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:dslzCdvG1UPhUs985e4264PY+yg= sha1:5Y+VrJEQjDNmoUYx5GzA+NWa52I= Xref: csiph.com comp.lang.python:80637 Ethan Furman : > On 11/12/2014 01:41 PM, Marko Rauhamaa wrote: >> >> Or I might indicate the exhaustion of possibilities: >> >> if status == OK: >> ... >> elif status == ERROR: >> ... >> else: >> assert status == WARNING >> ... > > And here's a nice example of what one should NOT do. Imagine that a > new status, CONFUSED is added, the above code is not modified to > handle it, and for whatever reason the program is being run optimized > -- the assert is not there, and CONFUSED is treated the same as > WARNING. How would it be better if you removed the assert then? Marko