class variable won't icrement!

Steve Holden sholden at
Thu Sep 12 17:57:00 CEST 2002

"Aahz" <aahz at> wrote in message
news:alq9hf$bn$1 at
> In article <alpner$bm$1 at>,
> Eric Brunel  <eric.brunel at> wrote:
> >
> >I always found that inheritance of class attributes to instance
> >was really misleading, and I even think it would be better if it were
> >simply removed from Python. IMHO, it would far more conform to the
> >"explicit is better than implicit" rule that is one of the basis of
> If I think of it as "scope resolution" rather than "inheritance", I find
> that it makes more sense.  It works exactly the same way as hiding a
> global with a local.

Well, not quite exactly the same way. If a local hides a global then there's
no way to access the global without explicit use of a namespace.

A class variable is available by instance-qualified name up until the time
the instance variable with the same name is created, which is why statements

    self.var += 1

can be so confusing. Especially when you compare operations that give
different results for mutable and immutable objects.

Steve Holden                        
Python Web Programming       
Previous .sig file retired to          

More information about the Python-list mailing list