Python cmd module command aliases

2019-07-16 05:11发布

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条回答
▲ chillily
2楼-- · 2019-07-16 05:55

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.

查看更多
登录 后发表回答