Self Nanny

Mark Hathaway hathawa2 at marshall.edu
Tue Mar 7 13:09:03 EST 2000


>> Gaetan Corneau <corg at copernic.com> writes:
>>
>> OK, I didn't make myself clear :)

> Lloyd Zusman wrote:
>
> Yes you have, at least for me.

me too

>> GC:
>>
>> 1) *I* don't mind having to specify "self" in method definitions
>>
>> 2) *I* don't mind having to write "self.Something"
>>
>> 3) BUT I think that it would be *nice* not to have to specify "self" in
>> method definitions, and it would certainly help A LOT of newbies
>>
>> 4) if possible at all, not having to write "self.Something" would be cool,
>> but not as important as #3
>>
>> And don't tell me #3 can't (technically speaking) be done :)

Personally, I'd rather not ever have to write 'self' or 'self.anything'.
It contributes nothing to the code and doesn't describe what I'm trying
to write. It's extra verbosity without any payoff.

Was there a problem with doing it the other way around...

    class aClass:
        def __init__(self,number):
            self.num = number
            n = self.num

    class aClass:
        def __init__(number):
            local.n = number

where the roles are reversed. All object attributes are
referred to by their names and any class (global) attributes
are specified by "local.". This would decrease tremendously
the need to write 'self.' and would still easily allow the
differentiation of class-wide attributes from object attributes.

Which do you write more of? Object attribute names.
Why make that the more verbose version?

> LZ:
>
> Of course #3 can be done (technically speaking).  And in return for it
> getting done, would you volunteer to donate your personal time to
> change all the existing lines of Python code in the world that this
> change would break?

This is both true and annoying. In our search for better ways to do
things we keep running into this barrier that languages are written,
tried and much time & effort put into that trial. Then when someone
says, "Couldn't we do it better this way?", the answer is, "But, we've
put so much work into this..."

Somehow there has to be a willingness to put the effort in and then,
if it's not as perfect as we'd like, throw it away and start with
another
piece of whole cloth. Well, perhaps we could write a translator to
convert
the old to the new. That wouldn't take quite as much man-power, would
it?

> Or barring that, would you be willing to pay for the time of all the
> others who would have to do this work?

Pay? Who paid the first time? Didn't most of the Python code come about
because people liked the language and just wrote stuff to be distributed
via the internet for free? O.K. here's a penny. Ya satisfied?

I know you're saying people's time & effort is considerable. All I'm
saying
is there should be ways to move to new better ways of doing things
without
having to face such stiff resistance.


> This is not an issue about "caring" about C++ programmers.  I am a C++
> programmer, and literally hundreds of my colleagues over the past
> decade or so have been C++ programmers.  Many of these people have
> tried Python.  And *none* of them have ever even made a complaint
> about the explicit "self" of Python.  You are the first C++ programmer
> I have encountered who has ever raised this as an issue.  That's one
> out of hundreds of people.

Perhaps they are simply more accepting of what is, and don't challenge
it.
That doesn't mean they haven't thought about it. I'm not a C++
programmer,
so I don't know either.

> And as I have mentioned in another post, I challenge you to come up
> any signficant number of people who would be glad to use Python if
> only it didn't have an explicit "self".

It's not just about that issue. It's about an effort to move toward
something better. You're not against that altogether, are you?

> Your arguments have always been clear.  And they are still rather
> unconvincing.
>  Lloyd Zusman
>  ljz at asfast.com


A closed mind can't even be convinced by the truth or a stick up side
the head.


P.S. I like Python. I'm still learning it (a real newbie). I even accept
     the indentation rule.  :-)


Mark Hathaway
e-mail: hathawa2 at marshall.edu



More information about the Python-list mailing list