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: try: