I'm using python to define a class, then append an instance of it to a list.
class town:
def __init__(name_, x_, y_, mayor_):
name = name_
main_x = x_
main_y = y_
mayor = mayor_
desc = desc_
def add_town(name_, x_, y_, mayor_):
towns.append(town(name_, x_, y_, mayor_))
town_number += 1
def onCommand():
add_town(args[1], loc_x, loc_y, sender.getName())
onCommand()
Unfortunately, I get this error when add_town is executed:
Caused by: Traceback (most recent call last): File "", line 95, in onCommandTown File "", line 74, in add_town TypeError: init() takes exactly 4 arguments (5 given)
Note: this is a shorted version of the code I'm using to keep things simple. Rest assured that all variables are defined correctly.
EDIT: Also, towns is a list.
Does anyone know why this error is here? I've been puzzling over it for half an hour and nothings happening...
selfargument in__init__