Attack a sacred Python Cow
Kay Schluehr
kay.schluehr at gmx.net
Fri Jul 25 01:06:35 EDT 2008
On 25 Jul., 03:01, Terry Reedy <tjre... at udel.edu> wrote:
> Torsten Bronger wrote:
> > Hallöchen!
>
> > And why does this make the implicit insertion of "self" difficult?
>
> > I could easily write a preprocessor which does it after all.
>
> class C():
> def f():
> a = 3
>
> Inserting self into the arg list is trivial. Mindlessly deciding
> correctly whether or not to insert 'self.' before 'a' is impossible when
> 'a' could ambiguously be either an attribute of self or a local variable
> of f. Or do you and/or Jordan plan to abolish local variables for methods?
>
> tjr
This isn't the problem Jordan tries to address. It's really just about
`self` in the argument signature of f, not about its omission in the
body. Some problems occur when not `self` shall be used but e.g.
`this`. Here one has to specify more:
class C():
__self__ = 'this' # use `this` instead of `self`
def f(a):
this.a = a
or
class C():
def f($this, a): # use `this` instead of `self`
this.a = a
When an $-prefixed parameter is found the automatic insertion of
`self` will be blocked and the $-prefixed parameter name will be used
instead but without the prefix.
More information about the Python-list
mailing list