cmd module question

Alex Martelli aleaxit at yahoo.com
Fri May 18 04:58:32 EDT 2001


<jedi at ccrypt.net> wrote in message
news:mailman.990166766.17981.python-list at python.org...
    ...
> I've run my code through the interpeter and read through the cmd.py module
> file to figure out what I'm doing wrong..  I can't seem to locate where
> it's sending 2 args.
    ...
> class Reader(cmd.Cmd):
    ...
>         def do_get(self):

Read carefully the cmd module's docs:
"""
cmdloop([intro])
Repeatedly issue a prompt, accept input, parse an
initial prefix off the received input, and dispatch
to action methods, passing them the remainder of
the line as argument.
"""

The "passing the remainder of the line" is the key.
Clearly, cmdloop() must be calling the equivalent
of:
    self.do_get(remainder)
or else how would it "pass the remainder"?

This IS calling do_get() with two arguments: the
implicit 'self', plus the explicit 'remainder'.


So, just change your method definition to:
    def do_get(self, junk):
        ...etc...


Alex






More information about the Python-list mailing list