A better self

Erik Max Francis max at alcyone.com
Tue Jul 9 19:17:15 EDT 2002


David LeBlanc wrote:

> I notice that in every discussion of self, there's always a '.' in
> there.
> So, why not make a leading '.' mean self? AFAIK, it's otherwise
> currently
> illegal. The only drawback that I can think of is that it's less
> visible as
> a first argument for class defs.
> 
> class foo():
>         def __init__(., me, me2, me3)
>                 .a = me
>                 .b = me2
>                 .c = me3
>         def fee(.)
>                 print .a, .b, .c
>         def bar(.)
>                 .fee()

This doesn't totally revolt me, but I would prefer that the "self"
argument still be an explicit self:

	def __init__(self, me, me2, me3) ...

so that the notation `.attribute' is just a shortcut for
`self.attribute'.  Having the "self" argument written as . suggests that
accessing an attribute in it should involve an extra space, e.g.
`..attribute' which is clearly not what you meant.

`self' as the name of that first argument is already so entrenched it's
really hard to come up with reasonable arguments about replacing it.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ See the son in your bad day / Smell the flowers in the valley
\__/ Chante Moore
    Bosskey.net: Aliens vs. Predator 2 / http://www.bosskey.net/avp2/
 A personal guide to Aliens vs. Predator 2.



More information about the Python-list mailing list