why self instead obj ?
peter at engcorp.com
Thu Mar 6 17:19:32 CET 2003
Gerard Breiner wrote:
> I am beginner in Python and i wonder why the first argument of the__init__
> function is called "self" instead "obj" whereas self indicates
> the object itself .
This doesn't make sense to me. What do you mean "whereas self indicates the
object itself"? Are you proposing that there is some meaning other than
what self currently means which you think would be appropriate for it? Or
are you really just proposing switching us all from self to obj?
> Moreover, "obj" is easier to type on the keyboard and shorter than "self".
Shorter, yes. Easier, debatable. I tried both and can hardly feel a
difference. Anyway, very little (if anything) in Python is about making
things "easier to type".
> However, i know i can use "obj" since "self" is a convention of naming, but
> it is better if everyone speaks the same language.
True, and since 99.999% of existing Python code uses "self", perhaps that
fact alone should put the discussion to bed, no? ;-)
> Other people would think that "this" is better (as in java), but "obj" seems
> to me more suitable.
Even allowing that you might be right, can you imagine the cost of getting
everyone to change? And what is the value of doing so? Very very little.
This is simply not going to happen. Get over it.
> What do you think about it ?
I think the discussion is exceedingly pointless given the absolute
impossibility that a suggestion to change from self to any other
spelling will ever prevail. *Maybe* self will go away someday, to
allow an implicit equivalent, but *never* will the spelling change.
More information about the Python-list