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

filter and modify list of dicts #47

Closed
quancore opened this issue Dec 25, 2020 · 5 comments
Closed

filter and modify list of dicts #47

quancore opened this issue Dec 25, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@quancore
Copy link

So I have a list of dicts like this (this dict could be in nested dict as well):
guilds = [{"ID":1, "Name":"x"}, {"ID":2, "Name":"y"}]

I want to modify the value of the Name key in the dict which ID is 1. I could not find how can I do that with the library.

@quancore quancore added the enhancement New feature or request label Dec 25, 2020
@fabiocaccamo
Copy link
Owner

You need to iterate over the dicts list and change the value if your condition is satisfied.

How would you expect to do it using this library?

@quancore
Copy link
Author

Actually, I already see a related issue here: #33
Some methods to combine key path and filters would be perfect like "key1.key2.['ID' == val].Name", so if the result is a shallow copy, I can modfiy.

@fabiocaccamo
Copy link
Owner

@quancore actually this is not possible.

This request seems to go in the direction of add xpath support, what do you think about it?

@quancore
Copy link
Author

Yes, all the roads going to a capable path conversion like XPath.

@fabiocaccamo
Copy link
Owner

I close this issue moving it to #67.

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

No branches or pull requests

2 participants