confused by bindings

Markus Schaber markus at schabi.de
Wed Sep 19 14:53:13 EDT 2001


Hi,

Sam Falkner <samf+usenet at frii.com> schrub:

> class Cell:
>     count = 0

This is the "class variable" called count.

>     def __init__(self, stuff):
>         self.count += 1

Here, you set an "instance variable" count. That's why you always get 1.

Try Cell.count += 1 here.

markus
-- 
"The strength of the Constitution lies entirely in the determination of 
each citizen to defend it. Only if every single citizen feels duty 
bound to do his share in this defense are the constitutional rights 
secure." -- Albert Einstein



More information about the Python-list mailing list