title: How to change all objects of a class at once?
body: <p>I am rediscovering OOP through a GUI application I am writing and would like to understand if it is possible to change a characteristic of all objects instantiated from a class. I have the following code:</p>
  
  <pre><code>class myclass():
      def __init__(self):
          self.a = 1
  
  x = myclass()
  y = myclass()
  print x.a, y.a  # outputs 1 1
  # the instruction I am looking for, assigns 2 to a in each object at once
  print x.a, y.a  # outputs 2 2
  </code></pre>
  
  <p>What I am looking for is a way to change <code>x</code> and <code>y</code> at once by manipulating the parent class. <strong>I know that I can have a method which modifies <code>self.a</code></strong> - I do not want to use that because it means I have to call it separately for each object.</p>
  
  <p>My gut feeling is that this is not possible and that I have to cleverly handle my objects to simplify such activities (for instance by storing them in a list I would loop over, applying a method). I just do not want to miss a mechanism which I am not aware of and which would greatly simplify my code.</p>