Getting rid of "self."

Jeremy Bowers jerf at
Sun Jan 9 19:01:55 EST 2005

On Mon, 10 Jan 2005 01:51:07 +0100, BJörn Lindqvist wrote:
> This is promising, I'm content with whatever slowdowns necessary as long
> as I can prove those who say "you can't do it" wrong. :)

Since I think I'm the only person in this discussion that said anything
about what you can't do, be clear on what I said. You can't have both of
undeclared attributes on self and no use of "self", in particular to add
new attributes. 

This is, if you take the time to understand what I mean, trivially true;
*somewhere* you need to declare whether a var is local to the function or
an instance member. For me, I prefer the explicit "self" and getting rid
of "self" now leaves you with the need to declare member variables
*somehow*, which I don't consider progress. But no matter what other magic
Alex works, you're only going to get one or the other; it's impossible for
the compiler to divine what you mean otherwise.

My point here isn't that you "can't" hack together code to do something
like what you want, and it is certainly a valid exercise in plumbing the
depths of Python and learning. My point is that you'll have to pay a price
in other ways. You can't make self go away "for free". And that "can't" I
do mean.

(You weren't necessarily claiming you could. But I thought it still worth
saying; even if you weren't trying to remove "self" "for free", others
certainly would mean it.)

More information about the Python-list mailing list