Steven D'Aprano wrote:
imp.find_module is deprecated and should not be used in new code.
...
try:
block
except (ImportError, RuntimeError):
block
Thanks Steven and others who replied. Looks more elegant.
By the way, RuntimeError is almost never something you want t
On Thu, 05 Apr 2018 23:04:18 +0200, ElChino wrote:
> I'm trying to simplify a try-except construct. E.g. how come this:
>try:
> _x, pathname, _y = imp.find_module (mod, mod_path)
> return ("%s" % pathname)
imp.find_module is deprecated and should not be used in new code.
Putting th
Ben Bacarisse wrote:
Anyway, to coalesce two or more exception handlers, you are probably
looking for
except (ImportError, RuntimeError):
To the OP: Are you sure you really want to mask RuntimeError here?
Usually it means something has gone seriously wrong, and is a
symptom that shouldn't be
ElChino writes:
> I'm trying to simplify a try-except construct. E.g. how come
> this:
> try:
> _x, pathname, _y = imp.find_module (mod, mod_path)
> return ("%s" % pathname)
> except ImportError:
> pass
> except RuntimeError:
> pass
> return ("")
>
> Cannot be simplified
On Thu, Apr 5, 2018 at 3:04 PM, ElChino wrote:
> I'm trying to simplify a try-except construct. E.g. how come
> this:
> try:
> _x, pathname, _y = imp.find_module (mod, mod_path)
> return ("%s" % pathname)
> except ImportError:
> pass
> except RuntimeError:
> pass
> return
On 04/05/2018 02:04 PM, ElChino wrote:
I'm trying to simplify a try-except construct. E.g. how come
this:
try:
_x, pathname, _y = imp.find_module (mod, mod_path)
return ("%s" % pathname)
except ImportError:
pass
except RuntimeError:
pass
return ("")
Cannot be si
I'm trying to simplify a try-except construct. E.g. how come
this:
try:
_x, pathname, _y = imp.find_module (mod, mod_path)
return ("%s" % pathname)
except ImportError:
pass
except RuntimeError:
pass
return ("")
Cannot be simplified into this:
try:
_x, pathname, _y