self (was: Python component model)

Ilias Lazaridis ilias at lazaridis.com
Wed Oct 11 21:36:32 EDT 2006


Peter Maas wrote:
> Paul Boddie wrote:
> > People who bring up stuff about self and indentation are just showing
> > their ignorance, in my opinion, since Python isn't the first language
> > to use self in such a way, and many C++ and Java programs use this
> > pervasively in order to make attribute scope explicit, whereas the
> > indentation matter is only troublesome with bad editing practices. I
> > don't think the community should spend any more time on these
> > criticisms.
>
> How many programmers don't use Python because of the self issue?
> I'm not for changing the semantics here but when I wrote a method with
> lots of selfs recently I tried how it would look like if it would be
> allowed not to write down 'self', i.e. from
>
> def deposit(self, amount):
>     self.balance = self.balance + amount
>
> to
>
> def deposit( , amount):
>     .balance = .balance + amount

would like this.

I finally liked pythons 'forced-indentation' thing, but 'self' is just
terrible.

def deposit(amount)
    .balance = .balance + amount # a little thin this dot
    @balance = @balance + amount # why not similar to ruby?

    self = <do this and that> # self remains available

but this will have most possibly major implications (design,
compatibility etc.)

possibly the simplest way would be to agree on 's' (typing is very
fast, faster than SHIFT-2 for @)

def deposit(s, amount)
    s.balance = s.balance + amount

so, python 2.6 = introduces agreement on 's' ?

this will never happen, but everyone is of course free to use 's'
instead of 'self' immedeately.

There's no problem (except possibly the tiny annoyancy when reading
through libraries which use 'self').

.

--
http://lazaridis.com




More information about the Python-list mailing list