Error when trying to pass list into function.
Stargaming
stargaming at gmail.com
Mon Apr 2 14:52:04 EDT 2007
erikcw schrieb:
> Hi,
>
> I'm getting the following error when I try to pass a list into a
> function.
>
> My List: crea =[(u'218124172', u'536', u'32394'), (u'218320282',
> u'1323', u'77931')]
>
> Traceback (most recent call last):
> File "wa.py", line 118, in ?
> curHandler.walkData()
> File "wa.py", line 49, in walkData
> self.results[parent][child]['results'] = self.calculate(crea)
> #pass in list of tuples
> TypeError: calculate() takes exactly 1 argument (2 given)
>
> def calculate(dta):
> #stub
>
> How can I make this work?
>
> Thanks!
> Erik
>
The first argument to a method (a function bound to an instance) is
always the instance itself. (I assume you *have* a method here because
you call self.calculate(crea), what will itself call
SomeClass.calculate(self, crea).)
For further information, consult the python tutorial
http://docs.python.org/tut/node11.html#SECTION0011400000000000000000.
HTH,
Stargaming
More information about the Python-list
mailing list