Giter Site home page Giter Site logo

Comments (3)

seperman avatar seperman commented on July 16, 2024

I see. I always found that syntax to be confusing too. That's why I added the grep syntax. What do you think about that? https://github.com/seperman/deepdiff#grep

from deepdiff import grep
obj = {"long": "somewhere", "string": 2, 0: 0, "somewhere": "around"}
ds = obj | grep(item)
print(ds)

from deepdiff.

maxrothman avatar maxrothman commented on July 16, 2024

The issue isn't a confusion in DeepSearch's syntax, grep produces the same result:

>>> from deepdiff import grep
>>> from uuid import uuid4
>>> foo = uuid4()
>>> {1: foo} | grep(foo)
{}

It's pretty clear where the problem is coming from. If you look at DeepSearch.__search_obj(), it treats any object it gets as a dict and searches its attributes without checking equality on the object itself.

It might be clearer to look at an example with None:

>>> {1: None} | grep(None)
{'unprocessed': ['root[1]']}

__search_obj() is looking for attributes on None, not finding any, and marking it unprocessed.

Would it be easier if I just made a PR?

from deepdiff.

seperman avatar seperman commented on July 16, 2024

Hi @maxrothman
Oh, I see what you mean now! Yes please make a PR if you have time.
Thank you.

from deepdiff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.