Wednesday 15 February 2012

python - Is there a sudo for os.remove() -



python - Is there a sudo for os.remove() -

i have existing file want remove, , next error when trying remove it:

os.remove(input_path) oserror: [errno 13] permission denied:

is there way remove file exists, other doing:

subprocess.call(['rm', input_path])

since you're getting "permission denied" error, clear there's "mismatch" between permissions of file (or parent directory), , of user running python process.

the best practice, instead of looking "shortcuts" in form of sudo, prepare permissions, either of file beingness deleted, or user running python process.

permissions used reason. you're risking getting troubles if take void/bypass them using tricks such sudo.

python

No comments:

Post a Comment