title: Dynamically call a var inside string in function
body: <p>I'm new to python, I have var (string) which is an <em>Xpath</em> query. I want to pass the variable <em><code>i</code></em> into the <em>Xpath</em> query. A simple example  below:</p>
  
  <pre><code>i = 0
  self.var = 'li['+i+']'
  
  def test(self):
    while(i&lt;10):
     print self.var #  'li[0]', 'li[1]' ...
     i += 1
  </code></pre>