Instance attributes vs method arguments

Aahz aahz at pythoncraft.com
Wed Nov 26 14:23:47 EST 2008


In article <mailman.4506.1227604887.3487.python-list at python.org>,
M.-A. Lemburg <mal at egenix.com> wrote:
>
>It is always good practice to provide default values for instance
>variables in the class definition, both to enhance readability and to
>allow adding documentation regarding the variables, e.g.

Actually, my company uses an occasional pattern of detecting whether an
attribute has ever been set with hasattr().  I am not particularly fond
of that mechanism because it has been the occasional source of subtle
bugs, but I also see the utility.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan



More information about the Python-list mailing list