Cmd Module

Godwin Burby godwinburby at gmail.com
Wed Nov 23 02:48:15 EST 2005


Dear Pythoneer,
        I was just curious about using the cmd module for building my
own command line interface. i saw a problem. The script is as follows:

from cmd import Cmd
import getpass

class CmdTest(cmd):
    def __init__(self):
        super(CmdTest, self).__init__()

    def do_login(self):
        passwd = getpass.getpass()
        if passwd = 'godwin': print "You are a valid user"

if __name__ == '__main__':
    ctest = CmdTest()
    ctest.cmdloop()

The interpreter reports that the first argument to super should be a
type rather than a class object and for the do_login function it says
that function needs only one argument but two are given. I solved the
above errors by adding the following code:

Cmd.__init__(self)

def do_login(self,passwd='godwin')

But i know that my first code should work without any problems or is
there a problem with it.
Pls enlighten me.




More information about the Python-list mailing list