TheFlyingDutchman <[EMAIL PROTECTED]> writes:

> The confusing way about the current Python method when you first
> encounter it is
>  why is "self" being passed in when you write the function but not
> when you call it. If the compiler is smart enough to know that
>
>     a = MyClass()
>     a.SomeFunction(12)
>
> SomeFunction() has a "self" implicitly added to the parameter list, it
> seems that it should be smart enough to know that a function defined
> in a class has a "self" implicitly added to the parameter list.

Several languages use the "object.method(args)" form, which is syntactic
sugar for "method(object, other_args)" which Ada, for instance, uses.
Knowing this clears up half the confusion (the object /is/ passed as a
parameter whichever syntax is used).

The other half of the confusion is cleared up by considering that
Python methods are ordinary functions that don't magically "know" in
which "class" context they are executing: they must be told via the
first parameter.

David Trudgett


-- 
These are not the droids you are looking for. Move along.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to