Le 06/11/2013 21:39, Skip Montanaro a écrit :
- assert 1 <= month <= 12, month
+ assert 1 <= month <= 12, 'month must be in 1..12'
In addition to Brett's comment, you might as well include the
offending value in your AssertionError message. For example, a value
of 0 probably tells you something different about your underlying bug
than a value of 2013. Just knowing it's out of range isn't really
enough.
Besides, if it's an assertion it's only an internal helper to check
implementation correctness. If it's an error that can be caused by
erroneous user data, it should be replaced with the proper exception
class (perhaps ValueError).
Regards
Antoine.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com