I love assert
Ethan Furman
ethan at stoneleaf.us
Wed Nov 12 17:47:06 EST 2014
More information about the Python-list mailing list
Wed Nov 12 17:47:06 EST 2014
- Previous message (by thread): I love assert
- Next message (by thread): I love assert
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 11/12/2014 02:41 PM, Ian Kelly wrote: > On Wed, Nov 12, 2014 at 3:13 PM, Anton <anschatten at gmail.com> wrote: >> On Wednesday, November 12, 2014 2:05:17 PM UTC-8, Ian wrote: >>> You don't need to remove it. Just reorganize it to make sure it >>> indicates actual exhaustion of possibilities. E.g. using the "assert >>> False" pattern from your post: >>> >>> if status == OK: >>> ... >>> elif status == ERROR: >>> ... >>> elif status == WARNING: >>> ... >>> else: >>> assert False >> >> If the code is run optimized and asserts are ignore CONFUSED statement would still not be handled and you will not know about it. >> I would do something like: > > There's no way to make the CONFUSED status be handled without actually > changing the code. The difference is that this version will not > incorrectly treat CONFUSED as WARNING; it just won't do anything at > all if the code is optimized. So, a different wrong thing, but still a wrong thing. ;) -- ~Ethan~
- Previous message (by thread): I love assert
- Next message (by thread): I love assert
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list