On May 17, 4:12 pm, Tim Chase <python.l...@tim.thechases.com> wrote: > On 05/17/2010 07:11 AM, kak...@gmail.com wrote: > > > While playing with the Python Standard Library, i came across "cmd". > > So I'm trying to make a console application. Everything works fine, i > > created many function with do_....(self, line) prefix, but when i > > tried to create a function with more arguments > > i can't make it work. e.g > > def do_connect(self, ip, command): > > >>>> connect 127.0.0.1 delete > > Are there any work arounds > > You simply receive all the text after the command: > > class C(Cmd): > def do_thing(self, arguments): > print repr(arguments) > > If you want to split it, you can do it boringly: > > def do_thing(self, arguments): > args = arguments.split() > > or you can let Python's standard library do some heavy-lifting > for you: > > import shlex > #... > def do_thing(self, arguments): > args = shlex.split(arguments) > > -tkc
Thanks, great answer!!! -- http://mail.python.org/mailman/listinfo/python-list