On Thu, Nov 5, 2015 at 2:41 PM, <zljubi...@gmail.com> wrote: > Raising an exception forces me to put every call of the get_html function in > try/except block. > If I am returning a special value, than I can call get_html and then test the > value. > > I am not sure which approach is better.
Raising an exception means that if you fail to put it in a try/except, you get a traceback that walks you through the exact location of the problem. Returning a special value means that if you fail to test the value, you either get an exception further on (if you get back None and try to treat it as a string, for instance), or get incorrect results, with no indication of the actual cause of the problem. Which would you prefer? ChrisA -- https://mail.python.org/mailman/listinfo/python-list