import a file from different directory
Question: i'm using python 2.7. I have written a script, i need to import a function
from some other file which is there in different folder. my script is in the
path

    
    
    C:\python\xyz\xls.py
    

Path of File having function that i need to call is

    
    
    C:\python\abc.py
    

i tried like this

    
    
    from python.abc import *
    

but it is not working. Is there any other way to call the function or i need
to move the files into same directory? Please help Thank you


Answer: You can dynamically load a module from a file:

    
    
    import imp
    modl = imp.load_source('modulename', '/path/to/module.py')
    

The [imp module docs](http://docs.python.org/2/library/imp.html) will give you
more details.

