On 18/04/19 1:24 PM, Cameron Simpson wrote:
On 17Apr2019 21:45, MRAB <pyt...@mrabarnett.plus.com> wrote:
On 2019-04-17 21:20, DL Neil wrote:
Do you bother with exception handling for import statements?
[...]
Catch only what you (well, the script) can fix.
If it needs numpy, but can't import numpy, then when can it do? Might
as well just let it fail.
I'm of this mind too, but...
I suppose an alternative might be to try to download and install numpy
and then retry, but what if it can't be downloaded, or the
installation fails?
As an example of what an open ended can of worms attempts recovery might
be, yeah. How hard do you try? But also, "installation fails": that
isn't always a clean situation: it can litter the install area with
partial junk.
But this is also a bad example: it is something an _invoked_ programme
should never try to do. Except by specific deliberate design and
request, a running application shouldn't presume it has rights to
install additional things, or even to try. I have personally (though
metaphorically) clipped devs across the ear for doing themselves the
moral equivalent of the above: try thing, then just "sudo try thing"
when it was forbidden.
...
+1
Installing additional packages is the same as self modifying code: as a
rule, the admins install packages, not the app.
+1
Sorry, ranting now over.
Not at all, an excellent point which needs to be taken out and
dusted-off, every now-and-again - particularly for such ear-clipping
training exercises!
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list