On Nov 17, 2013, at 11:05 PM, Maciej Fijalkowski wrote:
My problem with -O and -OO is that their arguments are very circular. Indeed, I understand the need why you would want in certain and limited cases to remove both docstrings and asserts. So some options for doing so are ok. But a lot of arguments I see are along the lines of "don't use asserts because -O removes them". If the option was named --remove-asserts, noone would care, but people care since -O is documented as "do optimizations" and people *assume* this is what it does (makes code faster) and as unintended consequence removes asserts.
The reason I want to split them is more because I'd like an option to remove docstrings but not asserts. As others have also said, I use asserts for conditions that can't possibly happen (or so I think). E.g. using an if/elif on an enumeration where the else should never be hit. Or saying that after some calculation, this variable can never be None. In a sense, assertions are executable documentation about the state of behavior at a particular line of code. If an assert ever *does* get triggered, it means you didn't understand what you wrote. -Barry