title: Python: pass string to be referenced in class (self.string)
body: <p>I have a Python question.</p>
  
  <p>Let's say we have this class:</p>
  
  <pre><code>class Class:
  
      def __init__(self, arg1, arg2, arg3):
          self.arg1 = arg1
          self.arg2 = arg2
          self.arg3 = arg3
  </code></pre>
  
  <p><strong>*******</strong> This part I am not sure how to code <strong>**</strong></p>
  
  <pre><code>    def controls(self, instructions)
          instructions[0] = instructions[1]
  </code></pre>
  
  <p><strong>*****************</strong>                 <strong>************</strong>    </p>
  
  <pre><code>    my_class = Class(arg1, arg2, arg3)
  
      inputs = {"A":[self.arg1, value1],
                "S":[self.arg2, value2],
                "D":[self.arg3, value3]}
  
      my_class.controls(inputs["A"])
  </code></pre>
  
  <p>So the dictinary ("inputs") maps keyboard strokes. According to what key is pressed, I need to edit some of the attributes of my_class.</p>
  
  <p>What I am trying to do is this: pass to def controls(self, instructions) the values that need to be edited according to the keystroke. So for example if the user presses "A", then I want to change self.arg1 to value1 from whatever value it has now. Similarly, if he presses "S", I want to edit another attributes to another, etc.</p>
  
  <p>So if I do:</p>
  
  <pre><code>print instructions
  </code></pre>
  
  <p>I get for keypress "A":</p>
  
  <pre><code>[self.arg1, value1]
  </code></pre>
  
  <p>So for example, if the user has pressed "A", "S" and "D", once all have been settle here is what my_class should look like:</p>
  
  <pre><code>my_class.arg1 = value1
  my_class.arg2 = value2
  my_class.arg3 = value3
  </code></pre>
  
  <p>I made various attemps, but none have been able to actually change the value of self.argX, they all either give me an error or don't accomplish anything useful.</p>
  
  <p>I am currently doing a bunch of If/elif but that's getting lenghty. </p>
  
  <p><strong>So my core question is this:</strong></p>
  
  <p>How can I pass as argument <strong>instruction[self.arg1, value1]</strong> and have the program edit whatever attribute I give it in <strong>instruction[0]</strong> and set its value to whatever value I give it in <strong>instruction[1]</strong> in my_class?</p>
  
  <p>Edit: removed details that aren't relevent to the core of the question after comments below.</p>