python - ObjectPath: trouble with "in" operator -
i learning objectpath python , have found out, e.g., how exact match on attribute:
>>> import objectpath >>> >>> tree = objectpath.tree({'doc': {'title': 'purple best color'}}) >>> >>> tree.execute('$..*[@.title "purple best color"]').next() {'title': 'purple best color'}
this makes sense me; want start root ($
) , recursively (..
) find (*
) items (@
) title == "purple best color". , works!
but try similar in
operator:
>>> tree.execute('$..*["purple" in @.title]').next() traceback (most recent call last): file "<stdin>", line 1, in <module> stopiteration
huh? seemed natural way tweak condition, it's not quite right.
in manual, read in
checks if result of left side of expression in array, object or string, , in objects, keys matched. (maybe that's issue, not sure quite means here). think current @
indeed string...?
considering above, missing here?
interestingly enough, explicitly converting purple
string works:
$..*[str("purple") in @.title]
created issue @ objectpath
issue tracker:
Comments
Post a Comment