title: Python Input TypeError: '_io.TextIOWrapper' object is not callable
body: <p>Could someone please explain why I get <code>TypeError: '_io.TextIOWrapper' object is not callable</code> with the input statement inside the  <code>Maze</code> function in the code below?</p>
  
  <p>I tested it outside of the function and it works fine. None of the answers in SO about this error seem to address my problem.</p>
  
  <pre><code># This program traverses a maze using a stack.
  
  from sq import Stack              # import a Stack type from sq.py
  
  MAZE_SIZE = 10                    # define the size of the maze
  
  def PrintMaze(maze):              # an auxilliary function that prints a maze
      for row in range(MAZE_SIZE):
          print(maze[row], end='')
      print()
  
  def InBounds(xxx_todo_changeme):              # an auxillary function that determines if (x,y) is on the maze
      (x,y) = xxx_todo_changeme
      return (0 &lt;= x &lt; MAZE_SIZE) and (0 &lt;= y &lt; MAZE_SIZE)
  
  def Maze(maze, start):          # traverse 'maze' from starting coordinates 'start'
      s = Stack()                  # create a new Stack named s
      s.push(start);               # push the start coordinates onto s
      while not s.isEmpty():       # loop while s is not empty
          (x, y) = s.pop()          # pop a coordinate off s into the tuple (x,y)
          input("press Enter to continue ")
          if InBounds((x,y)):         # if (x,y) is on the maze then
              if maze[x][y] == 'G':    # if (x,y) is the goal then
                  s.empty()             # empty the stack because we're done
              elif maze[x][y] == ' ':  # else if (x,y) is an undiscovered coordinate
                  maze[x] = maze[x][:y] + 'D' + maze[x][y+1:]  # mark (x,y) discovered with 'D'
                  PrintMaze(maze);      # print the maze to show progress so far
                  s.push((x+1, y))      # push right neighbor onto stack s
                  s.push((x-1, y))      # push left neighbor onto stack s
                  s.push((x, y-1))      # push upper neighbor onto stack s
                  s.push((x, y+1))      # push lower neighbor onto stack s
  
  # The following can be used to create a maze and traverse it:
  
  import sys
  input("press Enter to continue ")
  input = open('maze.dat', 'r')     # open the file 'maze.dat' for reading
  maze = input.readlines();         # read the file into maze
  Maze(maze, (0,0))                 # traverse the maze starting at (0,0)
  </code></pre>