On Wed, Nov 12, 2014 at 3:04 PM, Ian Kelly <ian.g.ke...@gmail.com> wrote:
> On Wed, Nov 12, 2014 at 2:56 PM, Marko Rauhamaa <ma...@pacujo.net> wrote:
>> How would it be better if you removed the assert then?
>
> 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

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.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to