Fredrik Lundh a écrit :
Eric Brunel wrote:
To add to what others have already said, it is not only 'just extra
work', it is also quite dangerous. See:
class A(object):
children = []
the OP is aware of that, of course:
> I set anything that is constant but anything variable is set again in
> __init__()
as long as if you're aware of the issues involved (which you should be
if you're using Python professionally), using class-level attributes is
a perfectly valid Python style.
Using class attributes is perfectly valid Python style, indeed. But in
this case - ie: using class attributes as a pseudo-declaration of
instance attributes -, I would not call this good style : it's a waste
of time, a violation of DRY, and a potential source of confusion for the
class's users / maintainers.
--
http://mail.python.org/mailman/listinfo/python-list