I agree: stacks and stacks of try / except statements can lead to indent
hell.

One way to cut that down is to use functions. Each function would try /
except a set of related operating systems, and if none of them work, raise
NotImplementedError. The main function would then just have to catch
NotImplementedError. It will cut down the bulk.

-tk

On Mon, Apr 15, 2019 at 2:56 PM Jon Marnock <jon.klo...@gmail.com> wrote:

> That is a good point, and it doesn’t look from that code as though windows
> is currently supported. I might take a look at writing something that does
> switch on OS with differing strategies. I kind of don’t like that approach
> in general (because it feels like the ‘ol “version check” in windows which
> everyone got so wrong for so png that MS actively fights you if you try and
> get that info on recent versions). Mostly though my issue is that OS
> versions aren’t necessarily correlated directly with methods - eg, until
> about 5.7 iirc, OpenBSD had a procfs you could use, but it was dropped.
> Arguably we should be testing fpr the existence of methods, not versions
> (the current exception driven design is actually closer to this, though
> just trying t and dealing with the fallout when it fails is perhaps less
> elegant!)

Reply via email to