I have the following standard import procedure:
from ROOT import *
Because of the way ROOT handles command line options and arguments, something like the following is required in order to avoid screwing up the script's command line parsing:
argv_tmp = sys.argv
sys.argv = []
from ROOT import *
sys.argv = argv_tmp
I need to perform this operation in many scripts. This operation may change or there might turn out to be a better approach, so I want to centralise this procedure in a single function provided by some imported module, making it easy to change the procedure in future.
def import_ROOT():
# magic
import os
import sys
import_ROOT()
import docopt
How can I import the ROOT module from within a function such that the result of the script's operation is the same as for the from ROOT import *
procedure described above?