Let's allow `assert`s again
assert
s in python are advertised as quick-and-easy checking tool to assert self-consistency within a program. They are used all over the place in the python eco-system and can help code be more readable (by making assumptions explicit) and avoid errors. The latter being the main reason for their existence.
However, assert
s are also sometimes misused to validate user-input. This is bad because assert
s can be disabled via a python optimization flag. To error on the side of caution, we decided to ban the use of assert
s in NIFTy.
I would like to revert this decision. I think the two upsides already mentioned - improved readability and avoiding errors - far outweigh the potential harm (basically no one enables these python optimizations [1]). I use a lot of assert
s in my own code base and on multiple occasions had to remove asserts from code submitted to NIFTy to conform with this policy. In short: IMHO NIFTy does not get better by disallowing assert
s.
@all What are you thoughts on this?
[1] python -O
enables basic optimization and removes all assert
s. With the -O
flag, python yields .pyo
files instead of .pyc
files. On my machine (with many, many python packages) not a single package installed a .pyo
file.