newbie: self.member syntax seems /really/ annoying

David wizzardx at
Wed Sep 12 12:36:21 CEST 2007

On 9/12/07, David <wizzardx at> wrote:
> > Please help if I am missing something -- this looks like a great
> > language but I am going to mad trying to read numerical code full of
> > 'self.'s breaking up the equations.
> You could try this in your functions:
> s = self
> Then you can use code like this: s.a_dot = s.k(s.a-s.u)
> Another option, if you use the vars a lot in a given function, is to
> copy them to local vars. This can also slightly speed up your code
> (fewer member lookups).

Also, there is no rule saying you need to use "self", it's just a
convention. You can declare your methods like this instead:

def foo(s, arg1, arg2):
  s.a_dot = s.k(s.a-s.u)

More information about the Python-list mailing list