[Python-ideas] class ModuleNotFoundError(ImportError)
Nick Coghlan
ncoghlan at gmail.com
Mon Feb 28 23:35:28 CET 2011
On Tue, Mar 1, 2011 at 7:28 AM, Guido van Rossum <guido at python.org> wrote:
> What might perhaps help is if ImportError had the name of the module
> that could not be imported as an attribute. Then the code could be
> rewritten as:
>
> try:
> import simplejson
> except ImportError, err:
> if e.module_name != 'simplejson':
> raise
> <backup plan>
Logged the suggestion: http://bugs.python.org/issue11356
Perhaps it it worth revisiting the old "import x or y or z as
whatever" syntax proposal for 3.3, since it could handle this idiom
internally (although deciding what, if anything to do for "from" style
imports is a hassle)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list