updating values of class attributes
<p>I have a class like the following:</p>

<pre><code>class MyClass(object):

    def __init__(self, input1, input2):
         self.attribute1 = [(a1_d1, a1_p1), (a1_d2, a1_p2)]
         self.attribute2 = [(a2_d1, a2_p1), (a2_d2, a2_p2), ..., (a2_d10, a2_p10)]
         ...some other attributes here...
</code></pre>

<p>The first coordinate in every pair is some decision/action and the second coordinate is the probability with which that action is chosen. I want to write a function that updates these probabilities for an instance of this class as the program runs. The way probabilities are updated depends on the decision taken previously. For example, I can write functions of the following sort:</p>

<pre><code>    def update_probabilities_attribute1(self, decision):
        i = 0
        for action, current_probability in self.attribute1:
            SOME CODE HERE
            self.attribute1[i] = (action, new_probability)
            i = i + 1

    def update_probabilities_attribute2(self, decision):
        i = 0
        for action, current_probability in self.attribute2:
            SOME CODE HERE
            self.attribute1[i] = (action, new_probability)
            i = i + 1
</code></pre>

<p>The part SOME CODE HERE is common to two functions. Is there anyway that I can have one function instead of two different ones, which takes self.attribute1 or self.attribute2 as an input and updates it accordingly.</p>

<p>Thanks.                </p>
