Python cmd module command aliases

不问归期 提交于 2019-12-23 23:21:02

问题


I am making a command line interface in Python 3.1.1 using the cmd module.

Is there a way to create a command with more than one name e.g. "quit" and "exit"? Or would it just be a case of making a number of commands that all reference the same function?


回答1:


Yes, it would just be a case of making a number of commands that all reference the same function.

This is common. It often helps to provide multiple common aliases for a command. It makes the user's life simpler because the odds of them guessing correctly are improved.



来源:https://stackoverflow.com/questions/1446137/python-cmd-module-command-aliases

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!