Aargh! Function takes exactly x arguments, y given..

David C. Ullrich ullrich at math.okstate.edu
Thu Jun 21 08:40:20 EDT 2001


On Thu, 21 Jun 2001 03:10:51 GMT, "Chris Tavares"
<ctavares at develop.com> wrote:

>"David C. Ullrich" <ullrich at math.okstate.edu> wrote in message
>news:3b2f3759.467766 at nntp.sprynet.com...
>> On Mon, 18 Jun 2001 08:19:30 -0700, Erik Max Francis <max at alcyone.com>
>> wrote:
[...]
>> >
>> >Only thing I can think of is that you've got a confusion with bound and
>> >unbound methods; if you call an unbound method (C.f where C is a class
>> >and f is a method), then you need to provide an instance of C as the
>> >first method (the implicit self method becomes explicit).
>>
>> Or he's not calling the function that he thinks he is, possibly
>> because of an "import *".
>>
>> (I refrained from guessing at first cuz I didn't want to leave
>> anything out. Is there a natural third possibility?)
>>
>
>The problem I still hit quite often is this:
>
>class Foo:
>    def MyMethod( x, y ):
>        pass
>
>
>foo = Foo()
>foo.MyMethod(1, 2)
>
>Boom! Called with three args, expected two.

Right. That's the "first" of the two possibilities
mentioned. (It might be that always calling the
first parameter "self" instead of "x" would remind
you of its special status...)

>-Chris
>
>
>



David C. Ullrich
*********************
"Sometimes you can have access violations all the 
time and the program still works." (Michael Caracena, 
comp.lang.pascal.delphi.misc 5/1/01)



More information about the Python-list mailing list