I have the following code:
#!/usr/bin/python
import os
from sys import exit as EXIT
File = os.path.realpath(__file__)
dir = os.path.dirname(File)
os.chdir(dir)
path_file = os.path.join(dir,"path.txt")
filo = open(path_file)
lines = filo.readlines()
if len(lines) == 1:
path = lines[0]
else:
raw_input("Too many lines... ")
EXIT()
FILE = open(path)
When I run it I get error:
Traceback (most recent call last):
File "py/Zebra/zebra.py", line 20, in <module>
FILE = open(path)
IOError: [Errno 2] No such file or directory: 'C:\\Users\\user\\file.txt'
If the path would be hard-coded then I could do something like path = r"C:\path\to\file"
But since the variable was defined by other methods, I am not sure now to fix this :(