def readFile(self):
        """ Read a maze from an input file """

        fname = raw_input('Enter maze filename: ')
        try:
            f = open(fname)
            lines = f.readlines()
            f.close()
            # See if this is a valid maze
            lines = [ line for line in lines if line.strip() ]
            w = len(lines[0].split())
            for line in lines:
                row = line.split()
                if len(row) != w:
                    raise MazeReaderException, 'Invalid maze file - error in maze dimensions'
                else:
                    self.maze_rows.append(row)
        except (IOError, OSError), e:
            raise MazeReaderException, str(e)
 Read a maze from an input file 
recipes/Python/496884_Amaze__objectoriented_maze_generatorsolver/recipe-496884.py