On Sep 14, 2007, at 11:54 PM, David Trudgett wrote: > 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.
Yes, that is really the crux of the issue, though. While the former may be syntactic sugar for the latter, once any syntactic sugar has become prevalent enough, it becomes the expected norm and the latter becomes clutter or, at best, awkward. It's something that really just takes a little use until you get to the point where you don't usually think of it but, every so often, the thought creeps in. I'm not complaining, just pointing out if you step out of this particular box, you'll realize that it really is a pointless one. Saying, "because that's how Python does it" may be the only valid reason, but that argument is about on par with a six year old's "just because...". Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailman/listinfo/python-list