title: How to assign an operation like sum or substitute, etc., to a variable
body: <p>I want to do something like</p>
  
  <pre><code>class A:
      def __init__( self, left, right, op ):
          self.left = left
          self.right = right
          self.op = op
      def calculate( self ):
          self.number = op( self.left, self.right )
          return self.number
  </code></pre>
  
  <p>and use it, for example, like this:</p>
  
  <pre><code>a = A( 1, 2, + )
  a2 = A( 2, 3, * )
  </code></pre>
  
  <p>I tried to do</p>
  
  <pre><code>op = +
  op = __add__
  </code></pre>
  
  <p>but none of these worked. Can somebody tell is this possible (and if it is, how this is called, because I don't even know how to search it). Or the only possible way is to have a big, ugly <code>if-else</code> statement in <code>calculate</code> and check the value of <code>op</code>, which will be stored as <code>str</code>?</p>
  
  <p>Thanks!</p>