Dinesh B Vadhia wrote:
> I belong to the Old School where getting my head around OO is just one 
> big pain.  I write software by modularization executed as a set of 
> functions - and it works (some call this functional programming!).  
> Whenever I review Python books (eg. Lutz's excellent Programming Python, 
> 3ed) the code is laid out with Def's followed by Classes (with their own 
> Def's) which is as it should be.  But, the Def's on their own (ie. not 
> in Classes) are all of the form:
>  
>  > def abc(self):
>         <do something>
>         return <return list>
>  
> or,
>  
>  > def xyz(self, <parameter list>):
>         <do something>
>         return <return list>
>  
> I don't use 'self' in my def's - should I?  If so, why?

No. self is the first argument to a method - a function that is part of 
a class. That is the only place it should be used.

My guess is that you are seeing defs for methods that are presented out 
of context. In general it doesn't make sense (and would not work 
correctly) to add an extra self parameter to standalone functions.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to