Question: I want to make sure that I delete required files.
I have code something like

```
dir="/some/path/"
file = "somefile.txt"
cmd_rm= "rm -rf "+dir + file
os.system(cmd_rm)

```

The `dir` and `file` values are fetched from a database. How can I make sure I never end up running `rm -rf /`? 

What things should I check before doing `rm -rf`?

Answer: 
You might consider using [`os.remove()`](http://docs.python.org/library/os.html#files-and-directories) instead since it's a great deal less dangerous than what you're attempting.
There is a module called `shutil` that provides shell-like file manipulation. If you want to delete a directory and all files and directories in it then use `shutil.rmtree`.

However it is implemented in python so if you are deleting a huge number of files then spawning rm may be faster, but will fail if the path has a space in it.