Do I always have to write "self." ?

Remco Gerlich scarblac-spamtrap at pino.selwerd.nl
Fri Apr 28 13:58:56 CEST 2000


Louis M. Pecora wrote in comp.lang.python:
> > You *can* use another word for 'self' though, 's' or 'me' or something. But
> > it makes your code harder to read, of course...
> 
> You mean by doing something like
> 
> s=self

No, you can just declare methods like

class Foo:
   def Method(s,x):
      s.y = x

The name 'self' is just a convention.

-- 
Remco Gerlich,  scarblac at pino.selwerd.nl
This space intentionally left blank.



More information about the Python-list mailing list