explicit self revisited

Michele Simionato michele.simionato at gmail.com
Mon Nov 13 09:51:10 CET 2006

Peter Maas wrote:
> The Python FAQ 1.4.5 gives 3 reasons for explicit self (condensed version):
> 1. Instance variables can be easily distinguished from local variables.
> 2. A method from a particular class can be called as
>    baseclass.methodname(self, <argument list>).
> 3. No need for declarations to disambiguate assignments to local/instance
>    variables.
> All these reasons are valid and retained by the following suggestion: let
> self be represented by the dot <snip>

This suggestion has been discussed in the past (I remember having the
same idea
myself when I first learned Python). But at the end I believe the
explicit 'self' is
a better solution, because there are cases where it is useful to have
it (see Steven
d'Aprano's post) and also I like the fact that  I can spell it 'cls' in
classmethods and in
metaclasses. After a while one gets used to it and if you think a bit
it makes quite a
lot sense. Also, having the self explicit, makes Python object system
better (i.e.
it goes more in the direction of CLOS and less in the direction of

          Michele Simionato

More information about the Python-list mailing list