On 28 Feb 2006 15:54:06 -0800
[EMAIL PROTECTED] wrote:
> The issue I have with self. is that is makes the code
> larger and more complicated than it needs to be. 
> Especially in math expressions like: self.position[0] =
> self.startx + len(self.bitlist) * self.bitwidth
> 
> It really makes the code harder to read.  On the other
> hand, eliminating the self. would create other issues
> including readability with regards to which vars are
> instance vars and which come from somewhere else.
> 
> But what if we keep the '.' and leave out the self.  Then
> the example looks like:
> .position[0] = .startx + len(.bitlist) * .bitwidth

I think I'm not the only person who hates this idea. The "."
is just too cryptic, IMHO. The main objection is that it
would require "magic" to make it work, though.

However, there is a slightly less onerous method which
is perfectly legit in present Python -- just use "s"
for "self":

  def mymethod(s):
      # ...
      s.position[0] = s.startx + len(s.bitlist) * s.bitwidth
      # ...

"self" is NOT a keyword, it's just a convention.

While I still generally prefer to see "self", I still
consider the above pretty readable, and it goes more than
halfway towards your goal.

Others have suggested "_" instead of "s". However, IMHO,
it's less visible, takes up the same space as "s", and
requires the shift key, so I'd rather just use "s".

And yes, it's been discussed to death on the list. ;-)

Cheers,
Terry


-- 
Terry Hancock ([EMAIL PROTECTED])
Anansi Spaceworks http://www.AnansiSpaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to