On Sun, 15 May 2011 20:53:31 -0700, Gnarlodious wrote: > Can someone please explain what I am doing wrong? > > Calling script: > > from Gnomon import GnomonBase > Gnomon=GnomonBase(3) > > > Called script: > > class GnomonBase(object): > def __init__(self, bench): > # do stuff > > But all I get is: > TypeError: __init__() takes exactly 1 positional argument (2 given) > > I don't understand, I am only sending one variable. What does it think I > am sending two?
Whenever you call a method, the instance is automatically provided by Python as an argument (conventionally called "self") to the function. So, for any arbitrary method, the call: instance.method(arg) is converted to: type(instance).method(instance, arg) hence two arguments. My guess is that your GnomonBase __init__ method is *not* what you show above, but (probablY) one of the following: def __init__(bench): # oops, forgot self # do stuff def __init__(selfbench): # oops, forgot the comma # do stuff -- Steven -- http://mail.python.org/mailman/listinfo/python-list