I have a python script that reads some input from a file that is supposed to be in the same directory of the script:
with open('./input1.txt') as file:
F = file.readlines()
Do_Stuff(F)
I usually run the script from other directories (not the directory the script and input files reside), so it raises an IOError that it can't find the input file (as it is not in my current working directory). I don't prefer putting a full path for the input file since I want it to be portable- only both the script and input files have to be in the same directory.
Is there a way to indicate the script to look in its location directory not the directory I am launching it from?