3 ms·
A tool to search for Python code using jQuery-like selectors
- candu 11y agoInteresting idea, and a great exercise for learning more about parsing, CSS selectors, and command-line interfaces. One point of (hopefully) constructive criticism: I'm not completely sold on the CSS selector syntax. Attribute selectors are semantically meaningful in the DOM, not as much so in Python. Providing a more Pythonic query language might make it easier for users to guess the purpose of queries and to build complex queries of their own. For instance: class * extends IntegerField class FloatField class FloatField: def * class FloatField: def to* from collections import Counter or perhaps: class FloatField: def to*(foo) for * in *: if * is None (or perhaps even `for $1 in : if $1 is None`. There are probably better ways than what I described to express the wildcard part, especially if you want to distinguish these from `args`, `kwargs`...) Anyways, it's always awesome to see people putting their work out there, and I hope you'll continue to do so!
- caioariede 11y agoI agree with you. I'm also not convinced that these kind of selectors are good to match Python code. It was more an exercise to develop a generic library that helps implementing jQuery-like selectors [1]. Even if the project doesn't go too far, it was a good fun for my weekend. [1]: https://github.com/caioariede/pyq/tree/master/sizzle https://github.com/caioariede/pyq/tree/master/sizzle