Is this correct way to import python scripts residing in arbitrary folders?
<p>This snippet is from an earlier answer here on SO. It is about a year old (and the answer was not accepted). I am new to Python and I am finding the system path a real pain. I have a few functions written in scripts in different directories, and I would like to be able to import them into new projects without having to jump through hoops.</p>

<p>This is the snippet:</p>

<pre><code>def import_path(fullpath):
""" Import a file with full path specification. Allows one to
    import from anywhere, something __import__ does not do. 
"""
path, filename = os.path.split(fullpath)
filename, ext = os.path.splitext(filename)
sys.path.append(path)
module = __import__(filename)
reload(module) # Might be out of date
del sys.path[-1]
return module
</code></pre>

<p>Its from here: 
<a href="http://stackoverflow.com/questions/72852/how-to-do-relative-imports-in-python">http://stackoverflow.com/questions/72852/how-to-do-relative-imports-in-python</a></p>

<p>I would like some feedback as to whether I can use it or not - and if there are any undesirable side effects that may not be obvious to a newbie.</p>

<p>I intend to use it something like this:</p>

<pre><code>import_path(/home/pydev/path1/script1.py)

script1.func1()
</code></pre>

<p>etc</p>

<p>Is it 'safe' to use the function in the way I intend to?</p>
