title: Python: is it possible to initialize a class variable with the class's own method?
body: <p>I am wondering if it is possible to define a Python class with class variables initialized using a <code>@classmethod</code> of this class. Following code fails but explains what I mean:</p>
  <pre><code>class foo:
      a = 1
      b = 2
      c = foo.add(a, b)  # NameError: name 'foo' is not defined
      # c = a + b        # &lt;-want to achieve this, but it duplicates add(), 
                         # which is what I want to avoid
  
      @classmethod
      def add(cls, x, y):
          return x+y
  </code></pre>
  <p>Also tried <code>c = add(a, b)</code> but got <code>TypeError: 'classmethod' object is not callable</code>.</p>
  <p>Anybody has a clue? Any advice will be appreciated.</p>