how to import module from other directory in python?
Question: This is my directory tree

    
    
    Game/
       a/
          1.py
          ...
       b/
          2.py
    

In 2.py I want import function display from 1.py. First I keep both file in
same folder there is no problem.But how to import from other location?


Answer: try using [`imp`](http://docs.python.org/2/library/imp.html):

    
    
    import imp
    foo = imp.load_source('filename', 'File\Directory\filename.py')
    

this is just like importing normally now you can use the file use imported

you then use what you named it (in this case `foo`) like this:

    
    
    foo.method()
    

hope thats what youre looking for!

you can also try this:

    
    
    import sys
    sys.path.append('folder_name')
    

