How to Open files in Other Directories in Python

I was wondering if anyone can show me how to open another file from another directory in python and then return to the default script

My Code:

    Bootstrap_location= 'C:\ProgramData\TERMINAL\Boot_Strp'
    Bootstrap_App_Loc=os.path.join(Bootstrap_location+"Terminal_Bootstrapper.py")
    from Bootstrap_App_Loc import Terminal_Bootstrapper.py

Thanks in Advance

Answers


You need to add the path to the file if it is not already on the sys.path. The module name is the filename without the '.py'

import sys
sys.path.append('C:\ProgramData\TERMINAL\Boot_Strp')
import Terminal_Bootstrapper

Need Your Help

Re-enabling location services for iPhone app

iphone objective-c core-location cllocationmanager permission-denied

I have been struggling with the location service request for my iPhone app. If the user says "Don't allow", I'm stuck in my "this app needs location services in order to work"...

Problems removeChild of many elements

javascript html css3 css-animations

I have a function that creates div with the class animate (which uses css3 animations) and then deletes it when webKitAnimationEnd triggers. The problem comes when i have multiple divs: the functio...