0

I am being a noob trying to loop over a function from pyxero:

invoices = xero.invoices.filter(page = 1)

The above call returns a list of dictionaries which becomes blank when there are no more pages left: [] . So the iteration would stop when the count of elements in the current list/page would become 0. I am trying to loop and create one big list that contains the elements from page 1 and 2 etc appended

Thanks!

DBa
  • 261
  • 1
  • 3
  • 11

1 Answers1

0

Solution, (page needs to be string):

number = 1
list = []
data = xero.invoices.filter(since = datetime(2018, 1, 1), page = str(number))
while len(data) > 0 
    data = xero.invoices.filter(since = datetime(2018, 1, 1), page = str(number))
    list.append(data)
    number += 1
DBa
  • 261
  • 1
  • 3
  • 11