Danek Duvall wrote:
> On Sun, Aug 03, 2008 at 08:59:53PM -0500, Shawn Walker wrote:
> 
>>> repositoryconfig.py: 129: why this change?
>> pylint warning fix about definition of attribute outside of __init__.
> 
> Is that actually considered dangerous (or bad style), or is that just
> because it makes pylint's life harder, so it complains?  There are times
> when it's seemed to me that it's preferable to limit the scope of an
> attribute to a few methods on an object, even though it does require a
> little bit of care to contain references to it, but if it's actually
> non-pythonic, I'll take my lumps and declare everything at the top.

The best I can gather from reading the docs is the following related points:

1) You should use class attributes whenever possible so that pydoc can 
pick them up. Failing that, you should document them in the docstring 
for the class (if appropriate).

2) Adding attributes on-the-fly can cause inheritance problems since the 
attributes will be present at different states.

3) Is the object really complete without these attributes if someone 
instantiates the object and then uses dir() or dict, len, etc. on the 
class and doesn't find what they expect?

I could find no specific recommendation other than __init__ is intended 
for all initialization logic.

-- 
Shawn Walker
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to