title: Convert code from actionscript to python
body: <p>I am trying to convert a project from actionscript to python. Here is the actionscript code:</p>
  
  <pre><code>private static function parseSTUFF(_arg1):String{
              var _local4:String;
              var _local5:int;
              var _local2 = "";
              var _local3:int;
              while (_local3 &lt; _arg1.length) {
                  _local4 = _arg1.substr(_local3, 1);
                  _local5 = _local4.charCodeAt(0);
                  if ((((_local5 &gt;= 48)) &amp;&amp; ((_local5 &lt;= 57)))){
                      _local4 = String((int(_local4) ^ 1));
                  };
                  _local2 = (_local2 + _local4);
                  _local3++;
              };
              return (_local2);
          }
  </code></pre>
  
  <p>and here is my attemp in python</p>
  
  <pre><code>local4=''
  local5=0
  local2=''
  local3 = 0
  while (local3&lt;len(arg1)):
    local4 = arg1[1:]
    local5 = int(local4[0].encode("hex"))
    if ((((local5 &gt;= 48)) and ((local5 &lt;= 57)))):
      local4 = str((int(local4) ^ 1))
    local2 = (local2 + local4)
    local3 = local3+1
  
  print local2
  </code></pre>
  
  <p>For some unknown reason, my python code does not give the same value.
  What I am doing wrong? Someone could help me?</p>