newbie: self.member syntax seems /really/ annoying

timothy.soehnlin at gmail.com timothy.soehnlin at gmail.com
Thu Sep 13 14:10:03 CEST 2007


Why not use '_' as the self variable.  It is minimal and achieves
close to '.var', as '_.var' isn't that different.  I know its a little
perl-esque, but its not a bad convention if you are aiming to up
readability of your code.

class test:
   def __init__(self):
      _ = self;
      _.a = 0;
      _.u = 0;
      _.a_dot = 0;
   def k(self, val):
      return val**2; #not sure what k does
   def getA_Dot(self):
      _ = self;
      _.a_dot = _.k(_.a-_.u);




More information about the Python-list mailing list