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.
Assuming that your mentioning *rm -rf* is not just at random, but is exactly the command you need, why not just to call it? There is a lib allowing a greater integration with shell called [**sh**](https://github.com/amoffat/sh).

```
from sh import rm

path_to_delete = '/some/path'
if os.path.exists(path_to_delete):
    rm('-rf', path_to_delete)

```

PS Make sure you are not root and/or ask for user input to be extra cautious.
And, yes, smoke the man to avoid deleting a single file recursively ;)