python - How to exit the cmd loop of cmd module cleanly -
Ideally, at some command You must override the CMD. Postcmd (stop, line) Hook method executed immediately after the expiration of the command dispatch. This method is a stub in CMD; It is overridden by subwalse line command line that was executed, and the stop is a flag that indicates whether postcmd () will be aborted after execution call; This return value of the ACMD () method will be used to return the value of this method as the new value of the internal flag, which matches to stop; The interpretation continues because of the wrong return. and This method will return when the postcmd () method returns a true value postcmd () Is the return value of the do_ * () method related to the stop arbikar command ATAC. In other words: exit prompt, I will exit the program.
postcmd method:
cmdloop from the document:
Import the CMD Class Test (CMD. CMD): # Your stuff (do_XXX methods should do nothing or wrong ) Def do_exit (auto, * args): return True
Comments
Post a Comment