title: Changing class variable: good practice or not? (Python)
body: <p>I have a class <code>Foo</code>, containing a class variable <code>size</code>.
  I want to calculate the size the first time I create a <code>Foo</code> object and use the same for all subsequent objects, but not calculate the size again. For the sake of containing everything within the <code>Foo</code> class I came up with this code:</p>
  
  <pre><code>class Foo(object):
      size = -1
      def __init__(self,args):
          if Foo.size &lt; 0:
              Foo.size = some_calculation(args)
  </code></pre>
  
  <p>In my small tests, it does what I want. However, is this considered good practice? Is there a better way to do it?</p>