On Wed, Jul 30, 2008 at 2:46 PM, Matthew Fitzgibbons <[EMAIL PROTECTED]>wrote:

> Robert Dailey wrote:
>
>> On Wed, Jul 30, 2008 at 1:03 PM, Brett g Porter <[EMAIL PROTECTED]<mailto:
>> [EMAIL PROTECTED]>> wrote:
>>
>>    Robert Dailey wrote:
>>
>>        This is an example of a response I'm looking for:
>>        "The self parameter is required because the parser is a bit old
>>        and needs to know the exact object you're referencing"
>>
>>        This is _not_ an example of what I'm looking for:
>>        "Specifying self is a great mysterious thing that we should
>>        never question. Do not question the language! The language is
>>        mighty! Don't bring C++ to Python!"
>>
>>
>>    Fredrik Lundh has written a  very clear explanation of this at
>>
>> http://effbot.org/pyfaq/why-must-self-be-used-explicitly-in-method-definitions-and-calls.htm
>>
>>    (or http://bit.ly/3EUiCf if you don't feel like stitching that URL
>>    back together...)
>>
>>
>> This sounds like an article of opinion. He's not really given any reasons
>> other than "Well, it makes this easier or look better". True that
>> declarations are the determining factor in C/C++, however I was thinking of
>> more or less an implied 'self'. For example:
>>
>> # Consider this normal syntax:
>> class MyFoo:
>>    def DoFoo( self ):
>>        self._member = 6
>>
>> # Elimintating 'self' in the parameter list should still work as far as
>> the
>> # interpreter is concerned, since 'self' in this case now acts like 'this'
>> # in C++. The below code should be equivalent.
>> class MyFoo:
>>    def DoFoo():
>>        self._member = 6
>>
>> Given the code samples above, is there any technical reason why this
>> cannot be done? Thanks for the input guys, and thanks more over for keeping
>> this easy-going.
>>
>>
>> ------------------------------------------------------------------------
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
> Your first example could be written:
>
> class MyFoo(object):
>    def do_foo(the_foo_instance):
>        the_foo_instance._member = 6
>
> 'self' is not special the way 'this' is in C++. It's just a name for an
> object reference just like any other name for any other object reference.
>
> -Matt
>

Yes, I realize that it can have any name. But this does not change its
purpose. It was simply an example. In the second code snippet I gave you,
'self' would become a reserved word and a user would have to use that to
reference the object from which the function was called.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to