Class

The Jocker the_jocker at hotmail.com
Wed Nov 7 18:35:09 CET 2001


Traceback (innermost last):
  File "test.py", line 19, in ?
TypeError: __init__() not enough arguments; expected 5 got 1

def __init__(self, Plan, Domain, Email, Name):


> if choice == 1:
>     print 'Adding New User\n'
!!!!!>add = DataBase() //this one calls __init__
>     add.UserPlan = input("Username: ")
>     add.UserDomain = raw_input("Domain: ")
>     add.UserEmail = raw_input("Email: ")
>     add.UserName = raw_input("Name: ")



"Edy Lie" <ed at iterunet.com> wrote in message
news:9sah0q$hki$1 at newton3.pacific.net.sg...
> Hi I have setup a class but in the code i could not use it. Anyone care to
> explain ?
>
> #!/usr/local/bin/python
> import sys
>
> class DataBase:
>    def __init__(self, Plan, Domain, Email, Name):
>       self.UserPlan = Plan
>       self.UserDomain = Domain
>       self.UserEmail = Email
>       self.UserName = Name
>
> print '1. Adding New User'
> print '2. Search New User'
> print '3. View All User'
> print '4. Exit'
> choice = input("Please choose an option: ")
>
> if choice == 1:
>     print 'Adding New User\n'
>     add = DataBase()
>     add.UserPlan = input("Username: ")
>     add.UserDomain = raw_input("Domain: ")
>     add.UserEmail = raw_input("Email: ")
>     add.UserName = raw_input("Name: ")
>
> elif choice == 2:
>     print 'Search New User\n'
>
> elif choice == 3:
>     print 'View All User\n'
>
> elif choice == 4:
>     print 'Exit program ...'
>     sys.exit()
>
> else:
>     print 'Wrong input'
>     sys.exit()
>
>
>





More information about the Python-list mailing list