multiple values for keyword argument

Frank Dierkes Frank.Dierkes at googlemail.com
Sat Jan 29 08:43:44 EST 2011


On Sat, 29 Jan 2011 14:18:30 +0100, Tobias Blass wrote:

> On Sat, 29 Jan 2011, Francesco Bochicchio wrote:
> 
>>> class MainWin(Frame):
>>>         def create_edit(row,self):

>>>         def create_edit(self, row):
>>

>>
>>
> Ok it works now. So the problem was that python requires 'self' to be
> the first parameter?

If you define an instance method, the first parameter is always the 
instance passed to the method - regardless of the parameters name.

In your case the instance was passed to the row parameter. Then again you 
wanted to pass i to it. That's why the exception was raised. If you just 
had typed self.create_edit(i), then row would have been the instance 
(*self*.create_edit(...)) and self would have been i.

Naming the first parameter self is only a convention. It could be any 
other name, too.



More information about the Python-list mailing list