noob question: "TypeError" wrong number of args

Edward Elliott nobody at 127.0.0.1
Tue May 2 13:29:58 EDT 2006


bruno at modulix wrote:
>> that 1) b is an object not a module*, and 2) objects pass references to
>> themselves as the first argument to their methods.
> 
> Nope. It's the MethodType object (a descriptor) that wraps the function
> that do the job. The object itself is totally unaware of this.

It's shorthand, not to be taken literally.


>> Making people pass 'self'
> 
> s/self/the instance/
> 
>> explicitly is stupid
> 
> No. It's actually a feature.

potato, potahto.  


>> the first argument, leading to these kinds of mistakes.  The compiler
>> should handle it for you
> 
> I don't think this would be possible if we want to keep the full
> dynamism of Python. How then could the compiler handle the following code
> ?
> 
> class MyObj(object):
>   def __init__(self, name):
>     self.name = name

class MyObj(object):
  def __init__(name):
    self.name = name

And the rest should work fine.  When the interpreter sees a method
declaration, it can automatically 1) add the object instance parameter to
the signature, and 2) automatically bind the name self to the object
instance on dispatch.  Everything else is just as before.

>> but in practice you don't declare
>> self as a parameter to module functions
> 
> def someOtherFunc():
>   print "hello there"
> 
> m.someFunc = someOtherFunc
> m.someFunc()

Complete non-sequitor, what does this have to do with self?  




More information about the Python-list mailing list