-
Notifications
You must be signed in to change notification settings - Fork 6
Feat: Add len
builtin function to URLSearchParams
class
#45
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
Conversation
I had this in the class initially, but took it out. I think it's fine to have a Or would you use |
@bbayles thanks for your comment. I agree with you about keeping compatibility with the mainstream project, however, imho, adding magic methods could help to improve readability for Python developers, and make the API still being friendly. This PR does not remove the old API, but adds a more fancy way to use the Python API. |
@bbayles btw, the purpose of my idea is not to override the classic methods, but provide a Pythonic way to use them. |
Right, but do you have an idea of a limiting principle? Would you want the get/set functions as well? I'm trying to decide whether to add those too, and if not, whether length makes sense. |
If you mean adding |
I don't get why is this falling, Do you guys have any clue? |
Looks like it was an intermittent failure with one of the wheel builds. I've still not decided whether to make this a general purpose "multidict" data structure, so I'm holding off on merging. |
I looked into how other libraries and treat structures with repeated keys (e.g. request headers and query parameters). There doesn't seem to be a common approach:
Anyway, I'll merge in this Thanks! |
Hi @bbayles ! I apologize for my delay and being late to respond. I agree with you, however, I think we can create a discussion to address this in a general way. |
This change aims to use the built-in function
len()
for getting the search params passed to the classURLSearchParams
, instead of using thesize
property,len
is a more pythonic and idiomatic way to retrieve a count of items.Example of usage