Calling `__next__` before `__iter__` on `Paginator` gives error
PeterLombaers opened this issue · comments
The paginator class implements both __iter__
and __next__
, but if you call __next__
before __iter__
you get an error:
import pyalex
pager = pyalex.Works().paginate()
next(pager)
gives:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/peter/venv/lib/python3.10/site-packages/pyalex/api.py", line 137, in __next__
if self._next_value is None or self._is_max():
File "/home/peter/venv/lib/python3.10/site-packages/pyalex/api.py", line 132, in _is_max
if self.n_max and self.n >= self.n_max:
AttributeError: 'Paginator' object has no attribute 'n'
Given that the name of the class is Paginator
I expected it to be an iterator (i.e., allow calling __next__
).