Relative paths in open in Python 2.5 and 2.7 -
i have script in python 2.5 opens file
f=open("./inputs/variable_list.csv","r")
it takes path of script goes folder csv. if run same line in python 2.7 doesn't know path open file
traceback (most recent phone call last): file "c:\inro\emme\emme4\python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in runscript exec codeobject in __main__.__dict__ file "x:\daniel\training\model_runs\2010\iter0\write_model_setup_joan.py", line 6, in <module> f=open("./inputs/variable_list.csv","r") ioerror: [errno 2] no such file or directory: './inputs/variable_list.csv'
why cant python 2.7 handle path how 2.5 did? there way create 2.7 handle path 2.5 did?
your script don't seems executed @ same place in both cases.
maybe ou should add together @ beggining of 2.7 script lines:
import os os.chdir('/location/of/your/script')
python python-2.7 python-2.5
No comments:
Post a Comment