Is it better to use class variables or pass parameters?
steve at REMOVETHIScyber.com.au
Wed Mar 1 23:17:01 CET 2006
On Wed, 01 Mar 2006 11:32:02 -0800, 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?
That depends on whether the variable is conceptually an attribute of the
instance or a parameter.
Attributes of the instance should be made instance attributes by (as you
put it) slapping a "self" in front of it. Parameters of the methods should
be passed around as arguments to the methods.
More information about the Python-list