This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os # import the operating-system module | |
base_path = "" # introduce base_path this is configurable | |
rel_path = "" # introduce relative path the path within your WORKING directory | |
final_path = os.path.join(base_path, rel_path) # use this path for your work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os # import the operating-system module | |
print(os.getcwd()) # print current working directory of the script | |
fp = open("my_dir/file.ext") # open some file in the current working directory i.e. where script lives | |
# how does it know the location of file.ext | |
fp.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os # import the operating-system module | |
print(os.getcwd()) # print current working directory of the script | |
fp = open("file.ext") # open some file in the current working directory i.e. where script lives | |
# how does it know the location of file.ext | |
fp.close() |