Is it better to use class variables or pass parameters?
Dave Benjamin
ramen at lackingtalent.com
Wed Mar 1 16:53:54 EST 2006
On Wed, 1 Mar 2006, Derek Basch wrote:
> This one has always bugged me. Is it better to just slap a "self" in
> front of any variable that will be used by more than one class method
> or should I pass around variable between the methods?
As a general rule, I only turn a parameter into an instance variable when
it would otherwise be a parameter of all (or nearly all) methods. Though
this is perhaps an overly mechanical perspective, I like to think of
instance variables as implicit parameters to every method. It helps me
keep scope under control and encourages better cohesion.
--
.:[ dave benjamin -( ramen/sp00 )- http://spoomusic.com/ ]:.
"one man's constant is another man's variable" - alan perlis
More information about the Python-list
mailing list