[Python-ideas] syntax to continue into the next subsequent except block

Jim Jewett jimjjewett at gmail.com
Mon Sep 17 21:39:50 CEST 2012

On 9/16/12, Joshua Landau <joshua.landau.ws at gmail.com> wrote:
> On 16 September 2012 23:30, Cameron Simpson <cs at zip.com.au> wrote:

>> Having a ridiculous suite of a billion trite
>> subclasses to enumerate the return codes from a lower level (or more
>> "inner") library is just nuts.

If the library created them, it is distinguishing between them --
regardless of whether it distinguishes by name or by number.

> As said above, how is Library.MathError(5) more arbitrary than
> Library.UncalculatableMathError()?

Numbers are more likely to get shifted by accident when someone adds a
new value.

But the point isn't that codes are more arbitrary -- it is that a name
is more helpful when debugging.

> Yes, if you have an incomplete name list you will suffer. But so what? Just
> cover all your bases. If you are wrapping a program from a lower-level
> language, wrap *everything you need*. It's no different to any other aspect
> of wrapping libraries.

And, more to the point, wrap *only* what you need.  If you were
providing the sole wrapper for a library, then you might have a fairly
long translation list.  But if you're just using the library, only
create virtual subclasses for the conditions that you happen to care
about, and name them based on why they matter.


More information about the Python-ideas mailing list