3 ms·
What a terrible hack, but I also think try/catch with imports is a terrible idea. So in this case, the punishment for having a hacky cludge, is in itself having
by ameminator 5y ago
What a terrible hack, but I also think try/catch with imports is a terrible idea. So in this case, the punishment for having a hacky cludge, is in itself having a hacky cludge.
- ggm 5y agoWhy is try/catch with imports a terrible idea? I mean if you need bignum, sure you can't run without the bignum import. But if you only want nicely typeset messages for humans, whats wrong with continuing even without it?
- cozzyd 5y agoI think there are other ways to do it, like https://docs.python.org/3/library/importlib.html#checking-if-a-module-can-be-imported https://docs.python.org/3/library/importlib.html#checking-if... (though this only works in Python 3.4+ it seems, which might be a constraint and of course many codebases will predate this idiom)