Hi,
I'm trying to create a "command line" in Python, which makes a user input a certain command and its associated data, without the use of brackets.
So the user would input:
>>> test 1 2 3
So it would carry out a command:
def test(firstnum,secondnum,thirdnum):
return firstnum,secondnum,thirdnum
The operation I have in mind is much longer/different, and I just need a bit of guidance to get me started.
I have a command line:
usercmd= raw_input("Enter a command -->")
if usercmd == "exit":
exit
if usercmd == 'test %s %s %s' % (firstnum,secondnum,thirdnum):
test(firstnum,secondnum,thirdnum)
Now the first command, exit, works fine, but I don't know how to take user input from a command line.
The second command, which is supposed to take test and pass them off as strings to test, does not. I'm trying to do this without an "Enter first number:", "Enter second number:", "Enter third number" staged user inputs.
So the user would input:
Enter command: test 1 2 3
then the firstnum,secondnum,thirdnum get passed to test and it carries out its operations (in this case, returning the three values).
Can anyone think of a way to do this?
Thanks.