title: Maximum recursion depth exceeded in cmp, Python
body: <p>I am a beginning programmer in Python, trying to practice by building a <a href="https://esolangs.org/wiki/Brainfuck" rel="nofollow">BF</a> interpreter. However, it will not work with the Hello, World! program:</p>
  
  <pre><code>++++++++[&gt;++++[&gt;++&gt;+++&gt;+++&gt;+&lt;&lt;&lt;&lt;-]&gt;+&gt;+&gt;-&gt;&gt;+[&lt;]&lt;-]&gt;&gt;.&gt;---.+++++++..+++.&gt;&gt;.&lt;-.&lt;.+++.------.--------.&gt;&gt;+.&gt;++.
  </code></pre>
  
  <p>giving a <code>RuntimeError: maximum recursion depth exceeded in cmp</code>. My code is below.</p>
  
  <pre><code>import sys
  
  script, file = sys.argv
  
  
  tape, tapeslct, cmdslct = [0], 0, 0
  code = open(file)
  program = filter(lambda x: x in ['.', ',', '[', ']', '&lt;', '&gt;', '+', '-'], code.read())
  print(str(program))
  program = list(program)
  
  def execute(cmd):
      global tape
      global tapeslct
      global cmdslct
      if cmd == "+":
          tape[tapeslct] += 1
      if cmd == "-":
          tape[tapeslct] -= 1
      if cmd == "&gt;":
          tapeslct += 1
          if tapeslct == len(tape):
              tape.append(0)
      if cmd == "&lt;":
          tapeslct -= 1
      if cmd == ".":
          print(chr(tape[tapeslct]))
      if cmd == ",":
          tape[tapeslct] = ord(input())
      if cmd == "[":
          if tape[tapeslct] &gt;= 1:
              loopend = 0
              testfor = cmdslct
              while loopend == 0:
                  testfor += 1
                  if program[testfor] == "]" and tape[tapeslct] &gt;= 0:
                      testfor = cmdslct + 1
                      execute(program[testfor])
                  elif program[testfor] == "]" and tape[tapeslct] == 0:
                      loopend = 1
                      cmdslct = testfor + 1
                  else:
                      execute(program[testfor])
          else:
              while loopend == 0:
                  testfor += 1
                  if program[testfor] == "]":
                      loopend = 1
  while len(program) &gt; cmdslct:
      execute(program[cmdslct])
      cmdslct += 1
  </code></pre>
  
  <p>The <code>lambda</code> snippet was taken from another BF interpreter in Python, found <a href="https://github.com/pocmo/Python-Brainfuck/blob/master/brainfuck.py" rel="nofollow">here</a>.</p>
  
  <p>I've missed something, most likely.</p>