On Fri, Jul 23, 2010 at 2:46 PM, Nobody <nob...@nowhere.com> wrote: > On Fri, 23 Jul 2010 10:42:26 +0000, Steven D'Aprano wrote: > >> Don't write bare excepts, always catch the error you want and nothing >> else. > > That advice would make more sense if it was possible to know which > exceptions could be raised. In practice, that isn't possible, as the > documentation seldom provides this information. Even for the built-in > classes, the documentation is weak in this regard; for less important > modules and third-party libraries, it's entirely absent. >
You still don't want to use bare excepts.People tend to get rather annoyed when you handle KeyboardInterrupts and SystemExits like you would a UnicodeError. Use Exception if you don't know what exceptions can be raised. -- http://mail.python.org/mailman/listinfo/python-list