This is a little verbose; you should probably collapse the multiple-step construction of these into one statement, e.g:

    config_prompt = re.escape(cmdPrompt[:-1] + '(config)#')