Too many 'self' in python.That's a big flaw in this language.

Jorgen Bodde jorgen.maillist at gmail.com
Wed Jun 27 10:01:18 EDT 2007


I had the same feeling when I started, coming from a C++ background, I
forgot about self a lot, creating local copies of what should be an
assign to a class instance, or methods that could not be found because
I forgot 'self' .

Now I am 'kinda' used to it, as every language has some draw backs
(you can't please all). But, what about something in between like only
using the dot (.) for a shorter notation?

self.some_var = True

Could become:

.some_var = True

Which basically shows about the same thing, but you leave 'self' out
of the syntax. Ofcourse it should not be allowed to break a line
between the dot and the keywords, else Python would never know what to
do;

my_class()
.my_var = True

Should not be parsed the same as;

my_class().my_var = True

Just a suggestion. I am pretty happy with self, but I could settle for
a shorter version if possible.

- Jorgen


On 6/27/07, Roy Smith <roy at panix.com> wrote:
> Marc 'BlackJack' Rintsch <bj_666 at gmx.net> wrote:
> > Use a shorter name than `self` or an editor with auto completion.
>
> Of the two, I'd strongly vote for the auto completion (assuming you feel
> the need to "solve" this problem at all).  The name "self" is so ingrained
> in most Python programmers minds, that it's almost a keyword.  Changing it
> to "this" or "s" or "me" will just make your program a little harder for
> other people to understand.
>
> Changing it to "this" would be particularly perverse since it's not even
> any less typing.  In fact, on a standard keyboard, it's harder to type
> since it involves moving off the home row more :-)
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list