title: Python read XY coords from text file
body: <p>I have a text file with numbers stored in the following format:</p>
  
  <pre><code>93 407 77 400 94 365 109 372 
  135 312 180 328
  100 120 140 160
  </code></pre>
  
  <p>I want to place these values into two list. One for polygons and one for rectangles.  </p>
  
  <p>If a line has 8 numbers in it, then gets stored to the polygon list. If a line has 4 numbers in it, then it get stored in the rectangle list. Like so  </p>
  
  <pre><code>polygon=[ [93, 407, 77, 400, 94, 365, 109, 372] ]
  
  rectangle=[ [135, 312, 180, 328,], [100, 120, 140, 160] ]
  </code></pre>
  
  <p>I would then uses these values to draw either a rectangle or a polygon on a canvas.</p>
  
  <p>Here is what my code is so far: </p>
  
  <pre><code>class getXYCoords:
  
      def __init__(self, textFile):
  
          self.textFile = textFile
          polygon = []
          rectangle = []
  
          with open(self.textFile) as f:
  
              for line in f:
                  line = line.split() #strip EOL
                  if line: #lines (ie skip them)
  
                      # Stores values into polygon list
                      if len(line) == 8:
                          line = [int(i) for i in line]
                          polygon.append(line)
  
                      # Stores values into rectangle list
                      elif len(line) == 4:
                          line = [int(i) for i in line]
                          rectangle.append(line)
  
          return polygon, rectangle
  
  # Example program
  
  if __name__ == '__main__':
  
      #polygon = []
      #rectangle = []
  
      # Get XY coordinates
      polygon, rectangle = getXYCoords('HAMH HUTC XY.txt')
  
      print(polygon,'\n')
      print(rectangle)
  </code></pre>
  
  <p>When I run the program I get this error message:</p>
  
  <blockquote>
    <p>line 46 in module<br>
       polygon, rectangle = getXYCoords('HAMH HUTC XY.txt')<br>
       TypeError: <strong>init</strong>() should return None, not 'tuple'</p>
  </blockquote>