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.
First, I suggest you to use the `os.remove()` and `os.rmdir()` functions for working with things like that. You will end up with more portable code and less headache for checking command return.

To check what you are effectively attempting to remove (you may not want to just check "/"), you can use some regular expressions on the generated path or just add a base path to all path returned from you database (depending what you are doing ...).