"self" vs other names
tim at vegeta.ath.cx
Wed Oct 3 03:07:10 CEST 2001
Me parece que Courageous <jkraska at san.rr.com> dijo:
> On Thu, 27 Sep 2001 13:20:05 -0700 (PDT), "Sean 'Shaleh' Perry" <shalehperry at home.com>
> >> Again, which code reads more easily is a matter of taste. I just thought
> >> I'd mention the possibility.
> >not that I subscribe to this, but another common form is simply 's'. You get
> >things like 's.dict' or 's.pid'.
> I sometimes use a one letter abbreviation of the object type:
> class matrix:
> def f(m):
I most often use 'self' for consistency between programmers, JIC someone
else has to maintain my code.
OTOH, when dealing with man object attributes I often set the local var
d equal to self.__dict__. It comes in handy a lot. It's alot easier to
type repeatedly, and it sometimes forces me to come up with more
illustrative names for any var that might start with d. Sometimes those
old BASIC habits are hard to break...
PRINT @ 33 "A STRING"
And there are only 26-52 vars available, each allowed only a one-letter
identifier. Ya know, sometimes I really _don't_ miss my old TRS-80. It
didn't have Python! It's amazing how something like a TRS-80 was sooo
cool at the time, and now I cringe at the thought.
What would the world have been like if CP/M had won over (PC|MS)-DOS?
Did I listen to pop music because I was miserable...
Or was I miserable because I listened to pop music?
-- John Cusack, "High Fidelity"
More information about the Python-list