Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling __next__ before __iter__ on Paginator gives error #37

Open
PeterLombaers opened this issue Apr 16, 2024 · 0 comments
Open

Calling __next__ before __iter__ on Paginator gives error #37

PeterLombaers opened this issue Apr 16, 2024 · 0 comments

Comments

@PeterLombaers
Copy link
Contributor

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__).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant