I try to execute some python code but i face a problem with passing the parameters.
My python code is the following:
#!/usr/bin/python
import MySQLdb
class Sim(object):
def print_db_parameters(self):
print "Host = %s" %self.host
print "User = %s" %self.user
print "Password = %s" %self.password
print "Database = %s" %self.database
def main():
host = "localhost"
user = "root"
password = "root"
database = "sim"
sim_test = Sim(host,user,password,database)
sim_test.print_db_parameters()
if __name__ == "__main__":
main()
When i run it, i receive the following error:
Traceback (most recent call last):
File "Sim.py", line 21, in <module>
main()
File "Sim.py", line 17, in main
sim_test = Sim(host,user,password,database)
TypeError: object.__new__() takes no parameters
Do you have any idea?
You are passing parameters to a class constructor
But not accepting them. You must create an
__init__method to deal with them.