Add __len__ to ItemPaged class

See original GitHub issue

Is your feature request related to a problem? Please describe. For the class ItemPaged at

https://github.com/Azure/azure-sdk-for-python/blob/90fc2a709d9a20f7a3659255320c98d3beb8aa1e/sdk/core/azure-core/azure/core/paging.py#L84

It would be nice to add __len__ function.

Describe the solution you’d like

Because it’s an iterator using len() on it will give TypeError: object of type 'ItemPaged' has no len(). Yes you can use len(list()), but it’s too wordy.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mcapuccinicommented, Jun 29, 2021

This is such a basic requirement, couldn’t you add a count function? There are a lot of lazily loaded collections that do this.

1reaction
josiahdccommented, Sep 24, 2022

ditto to the above, len is such a fundamental attribute of any collection

Read more comments on GitHub >

github_iconTop Results From Across the Web

azure.core.paging.ItemPaged class - Microsoft Learn
This sample shows how to manage your storage account using the Azure Storage Management package for Python. The Storage Resource Provider is a...
Read more >
How should Azure ItemPaged iterator work? - Stack Overflow
The length of pathlist is 5000. According to documentation - it is default max_results for page, as the output of get_pages() is the...
Read more >
Making the len function work on your Python objects
In Python, you can make the built-in len function work on your objects. The len function only works on objects that have a...
Read more >
Python Guidelines: Implementation | Azure SDKs
LROPoller; ItemPaged; DiagnosticsResponseHook ... This is achieved by using the CaseInsensitiveEnumMeta class defined in azure-core .
Read more >
AttributeError: 'list' object has no attribute 'len' | bobbyhadz
To solve the error, pass the list to the `len` function to get its length, ... it returns a list of names of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found