Python cmd module: get the whole input in default method

246 Views Asked by At

I'm working on an cmd2 interface to my database and I want to be able to use it to quickly and continuously enter data into my database. I therefore want to do the inserts in the default method of cmd2.

def default(self, line):
    data = line.split()
    doStuffWith(data)

And in my particular database an insert would be with three words:

>13 ayer es

The problem is that cmd2 gets rid of the first word and only gives me 'ayer' and 'es' not '13'. I guess this is expected since the first word usually corresponds to the command but how do I get access to the whole line?

PS: solution for cmd or cmd2 framework both work since from what I've gathered cmd2 is just and extension of cmd. If not I could just as well use cmd.

1

There are 1 best solutions below

0
On BEST ANSWER

Found the answer myself!

To get the whole line I was supposed to use line.raw (which I found out by using repr(line))