
Feb. 28, 2011
11:35 p.m.
On Tue, Mar 1, 2011 at 7:28 AM, Guido van Rossum <guido@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@gmail.com | Brisbane, Australia