[Python-ideas] Mitigating 'self.' Method Pollution

Ben Finney ben+python at benfinney.id.au
Sat Jul 11 11:24:32 CEST 2015

Nick Coghlan <ncoghlan at gmail.com> writes:

> I read [Michael Hewitt's] proposal as aiming to cut down on visual
> *noise* when *reading*.

Okay. In response to that, then:

Michael appears to want most of those references to entirely omit the
explicit namespace.

The desire to entirely remove explicit namespaces to distinguish names
in a function, I don't sympatise with. Those explicit namespaces make
the code much more readable.

I don't know what Michael means by “clean”; if it is a simple “fewer
characters”, that's not strongly correlated with easier-to-read code.

Especially because readable code *also* requires clarity and rapid
comprehension – including disambiguation – of the writer's intent. For
those purposes, many times the better solution involves writing
significantly *more* characters than the strict minimum.

So arguments merely leaning on “fewer characters” don't impress me, and
I hope they don't impress many others.

As for simply choosing a shorter name:

> It's worthwhile to compare the different examples in terms of
> "characters conveying useful information":

Given that “self”, while merely a convention, is now such a strong
convention that it is hard-coded into many tools, I argue that “self”
conveys much *more* information than a different shorter name (such as
“s”). The latter will tend to require rather more effort to comprehend
the writer's intent, and to that extent is less readable.

 \       “The right to use [strong cryptography] is the right to speak |
  `\                                             Navajo.” —Eben Moglen |
_o__)                                                                  |
Ben Finney

More information about the Python-ideas mailing list