convert string to pre defined python variable
<p>I wanted to know How can I convert string to python defined variables.</p>

<p>Basically I want to do this.</p>

<pre><code>if value1 operator value2:
      print True 
</code></pre>

<p>my operator is a string <code>'==' , '&gt;', '&lt;', '!='</code>
  so that it becomes </p>

<pre><code>if value1 == value2:
      print True
</code></pre>

<p>I tried  <code>operator = getattr(sys.modules[__name__], operator )</code> but it work for class. 
thanks.</p>
