Why is this returning true? The docstring doesn't say it returns a boolean type, it sometimes returns None (if it actually executes the commands. No return statement is the same as returning None), and you never actually check the return value. If you just want to exit the function and not return a value (which it looks like is what you want), just use "return" without a variable. (again, this is the same as returning None).