title: Define variables using a list of names
body: <p>I am trying to do something dirty here in my script.</p>
  
  <p>I have a function that applies some transformations on an object called <code>model</code>. <code>model</code> can have several attributes, which includes <code>alpha</code> and <code>delta</code>. The function, however, must be able to override those attributes with its own optional parameters. </p>
  
  <p>I guess I have to check if the function has received those arguments and, if not, reassign the attribute to the flat name. (From <code>model.alpha</code> to <code>alpha</code>). The main issue here is to code the loop that solves this for any given case.</p>
  
  <p>The only way I have managed to do this is using the <code>locals()</code> dict, but I find that quite dirty. Any suggestions? Here is my code, roughly.</p>
  
  <pre><code> def transform(model, alpha=None, theta=None):
          for p in ('alpha', 'theta'): #the list is longer, actually
              if not locals()[p] and hasattr(model, p):
                  locals()[p] = getattr(model, p)
  
          _rotate(model, alpha)
          _translate(model, delta)
  </code></pre>
  
  <p>Finally, is there any internal list for the optional parameters of the function? Something like <code>__parameters__</code>? That way, I could just do <code>for p in __parameters__</code> and so on.</p>
  
  <p>Thank you!</p>