static variables?

John Roth newsgroups at
Fri Mar 19 20:30:13 CET 2004

<niurka.perez at> wrote in message
news:mailman.167.1079721766.742.python-list at
> How can I have a static variable in a python class in a similar fashion as
> have them in Java?
> I just want a share the same information in all the instances of a class
and if
> one of the instances changes this information, the rest of them will
notice the
> changes.
> I've been looking for this for a while and I'll appreciate your help
> Niurka

The easiest way is to simply define it in the class, and
then always qualify it by the class when doing an assignment.

class foo:
    bar = "xyzzy"

    def it(self, new): = new


John Roth

More information about the Python-list mailing list