Attack a sacred Python Cow

Terry Reedy tjreedy at udel.edu
Sat Jul 26 23:49:17 CEST 2008



Paul Boddie wrote:
> On 26 Jul, 06:06, Terry Reedy <tjre... at udel.edu> wrote:
>> Paul Boddie wrote:
>>> "The problem is that the explicit requirement to have self at the
>>> start of every method is something that should be shipped off to the
>>> implicit category."
> 
> Here, I presume that the author meant "at the start of every method
> signature".
> 
>> There is no requirement to have 'self' in the parameter list.  It can be
>> 's', 'this', 'me', 'yo'(Spanish for I), or 'cls' (for class methods), or
>> any other identifier in whatever language.
> 
> But Jordan apparently wanted to omit that parameter. The omission of
> all mentions of "self" could be regarded as a bonus, but it's a non-
> trivial goal.

Reword.  There is no requirement to name the instance anything in 
particular.  Thus there is no requirement at present that the first 
parameter, which gives the name of the instance, be anything in 
particular.

>> In 3.0, identifiers are not restricted to ascii but can be any unicode
>> 'word' as defined in the manual.
>>
>> So the proposal would have to be that the compiler scan the function
>> body and decide which dotted name prefix is the one to be implicitly
>> added.  Have fun writing the discovery algorithm.  However, I think this
>> is pretty silly.  Just write the name you want.
> 
> If, as I wrote, you permit the omission of "self" in method signatures
> defined within class definitions, then you could still insist on
> instance attribute qualification using "self" - exactly as one would
> when writing Java according to certain style guidelines.

Which is what I said in the first sentence of my next paragraph, which 
you clipped.
"Or the proposal would have to be that 'self' is mandatory for all 
programmers in all languages."  To clarify " ... that 'self' be the 
mandatory instance name for all Python programmers regardless of 
inclination or the natural language they otherwise use as a basis for 
identifiers."

In sum, if the instance name is omitted from the parameter list, it must 
either be discovered or mandated, and def statements in direct class 
scope have to be treated differently from def statements elsewhere.

Terry Jan Reedy




More information about the Python-list mailing list