You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Confusing behavior when using star globs and list indexing #166
When using dpath.util.search retrieves an empty list, it won't include it in the result:
>>>importdpath.util>>>a= {'a': {'b': []}}
>>>b= {'a': {'b': [1, 2, 3]}}
>>>dpath.util.search(a, 'a/b/*') # expecting {'a': {'b': []}} here
{}
>>>dpath.util.search(b, 'a/b/*', afilter=x>3ifisinstance(x, int) elseTrue) # should again give {'a': {'b': []}}
{}
>>>dpath.util.search(a, 'a/b')
{'a': {'b': []}}
I find this behaviour counterintuitive: I tend to "pronounce" the star as "give me all items in this location". Hence if the item is an empty list, then I want that empty list. Am I misunderstanding something here? What would be the expected behaviour? Also, the final call illustrates something that I find particularly strange here: I would think of both globs to give the same results, but they don't seem to do so.
A second confusing thing seems to be the handling of numeric indexes for lists:
@igordertigor
Please review the changes on #172 which add support for negative number indexing.
I've started investigating the other issue and it seems to be more problematic. I'm not sure I will be able to resolve it. Follow #173 for updates on that.
Thanks @moomoohk for looking into that. I didn't comment on #172 because it was already merged. Regarding #173, I'm not entirely sure if I understand what exactly the issue is. But that might be my limited insight into dpath's internals.
Activity
moomoohk commentedon Dec 1, 2022
Hi @igordertigor,
Negative indexing is not supported at the moment. I am currently experimenting with this feature on #171.
I will also investigate the first issue you mentioned with the stars.
Regards
moomoohk commentedon Dec 2, 2022
@igordertigor
Please review the changes on #172 which add support for negative number indexing.
I've started investigating the other issue and it seems to be more problematic. I'm not sure I will be able to resolve it. Follow #173 for updates on that.
moomoohk commentedon Dec 4, 2022
Negative index suggestion also appears in #138.
igordertigor commentedon Dec 8, 2022
Thanks @moomoohk for looking into that. I didn't comment on #172 because it was already merged. Regarding #173, I'm not entirely sure if I understand what exactly the issue is. But that might be my limited insight into dpath's internals.
moomoohk commentedon Dec 8, 2022
Sorry the issue closed automatically. I'm reopening until the second issue is resolved.