On Wed, Oct 13, 2010 at 9:56 AM, Seebs <usenet-nos...@seebs.net> wrote: > On 2010-10-12, MRAB <pyt...@mrabarnett.plus.com> wrote: <snip> >> Line 51 > >> The __init__ method should always return None. There's no need to be >> explicit about it, just use a plain "return". > > The real issue here is that I was assuming that open('nonexistent') returned > None rather than raising an exception.
For future reference, the significant majority of things in Python raise exceptions upon encountering errors rather than returning error values of some sort. Aside from APIs which explicitly provide a parameter to be returned as a default value in case of error (e.g. getattr(obj, name, default)), the only common exception* I can come up with off the top of my head is str.find()**, and even that has an exception-throwing cousin, str.index(). Cheers, Chris -- *No pun intended; I just didn't want to have to break out a thesaurus. **Returns -1 rather than raising ValueError -- http://mail.python.org/mailman/listinfo/python-list