Think better way to do this is (without all this for loop stuff):

    index = kwargs.get('index', None)
    if index:
       if rows is None:
          rows = index
       else:
          raise