Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #55746

Re: multiple values for keyword argument

From Frank Dierkes <Frank.Dierkes@googlemail.com>
Newsgroups comp.lang.python
Subject Re: multiple values for keyword argument
Date 2011-01-29 13:43 +0000
Message-ID <8qijsgFgu1U1@mid.dfncis.de> (permalink)
References <alpine.LSU.2.00.1101291200340.7991@Tux.site> <9f669337-6116-4442-9c7e-54b0051e33a2@8g2000prb.googlegroups.com> <alpine.LSU.2.00.1101291417350.7717@Tux.site>

Show all headers | View raw


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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: multiple values for keyword argument Frank Dierkes <Frank.Dierkes@googlemail.com> - 2011-01-29 13:43 +0000

csiph-web