Object of type 'SyncV4PagePaginationArray[Zone]' has no len()
Confirm this is a Python library issue and not an underlying Cloudflare API issue.
- [x] This is an issue with the Python library
Describe the bug
When trying to get the length of the zones array returned by the zones list call, an error is raised.
TypeError: object of type 'SyncV4PagePaginationArray[Zone]' has no len()
According to python standards, len should be used to return the number of elements of an array. Since SyncV4PagePaginationArray is indeed an Array, it should probably inherit its method, or else, another method should be provided and properly documented.
To Reproduce
Use the len function on a SyncV4PagePaginationArray[Zone]
Code snippets
client = Cloudflare()
zones = client.zones.list()
len(zones)
OS
linux
Python version
3.9.0
Library version
v4.0.0
Hey @miguelvillarhpecds, the reason we didn't implement len() is because we were concerned about it being a footgun as users could expect it to return the size of all of the entries instead of just the entries in the current page.
To check the length of the response you can use len(page.result) which makes this behaviour more explicit.
I can see how the Array part of the class name is confusing though, will look into improving that.
@RobertCraigie is this one by design? Let me know if we should close it out.
yeah this is by design.
the pagination naming including Array is a different issue that we can track separately.