It's easy to find people asking how to do this, but there is never an answer that applies to me from what I can tell. I simply want to create permissions, in generality, to write to new files in a subdirectory. Within python I call
filename = 'dfs_err_results/err_results_st'+str(station_id)
file = open(filename,'w')
pickle.dump(results, file)
file.close()
but it fails at open()
with IOError: [Errno 13] Permission denied: 'dfs_err_results/err_results_st5'
. If I enter with sudo python
, that error doesn't occur, but it's annoying to have to remember that and to have to check progress within sudo ps x
where there are a ton of processes.
Am I correct there's no way to alter the subdirectory for future files using chmod? Or no way to have lines of code within the python script that set the permissions?
Thanks!