tags:

views:

153

answers:

1

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?

+2  A: 

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.

S.Lott
From a performance issue would it be a bad idea to have a lot of them or is it negligble?
Mr_Chimp
You'd never be able to measure the difference. It's just class method dispatching -- which uses a hashing algorithm -- so the complexity is **O**(1). Adding a few extra method functions or having one method function call another involves microscopic overhead.
S.Lott