Rather than including the leading space in all of the command.appends above, how about `' '.join(command)` here?