* Guillaume Martel-Genest <guillaum...@gmail.com> [110621 12:53]: > What is the pythonic way to handle imports error? What is bugging me > is that the imports can't be inside a function (because I use them in > different places in the script and thus they have to be in the global > scope). I would write something like: Suppose you do something like this: try : mod = __import__('mymodulename') except ImportError: pass ## replace with error handling here
so `mod' is global if you execute the above code as top-level, *but* you can also pass `mod' as an argument like any other variable, as far as I know and far as I have done. -- Tim tim at johnsons-web dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list