astsearch

39 views
Skip to first unread message

Aaron Meurer

unread,
Apr 30, 2014, 12:30:29 PM4/30/14
to sy...@googlegroups.com
Some people on this list might find this useful.
http://takluyver.github.io/posts/astsearch-code-searching-that-knows-about-code.html

We often grep the codebase to do refactorings, or fix some API, or
whatever. This uses Python's ast to search, meaning it will filter out
false positive, and should also work with things that span multiple
lines (and you don't have to worry about whitespace).

As an example, to find all instances of .args in code (as opposed to
strings and comments), you could do

astsearch ?.args sympy/

Aaron Meurer

Brian Granger

unread,
Apr 30, 2014, 1:05:38 PM4/30/14
to sympy
Yes, I saw this - very beautiful!
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6JQpXRF0Pmd-BvXjXpvShLGWNs7BicW0%3DyfO_JdxDsz3Q%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian E. Granger
Cal Poly State University, San Luis Obispo
bgra...@calpoly.edu and elli...@gmail.com

Ondřej Čertík

unread,
Apr 30, 2014, 1:16:33 PM4/30/14
to sympy
Indeed, that's awesome.

Ondrej
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAH4pYpSLgRAZ9rk-bLAbc1pcGYHBkf6wAL4QB1fAHmM844fgjA%40mail.gmail.com.

F. B.

unread,
May 2, 2014, 2:18:37 PM5/2/14
to sy...@googlegroups.com
I use either Eclipse with the PyDev plugin, or vim and ctags. They can both perform regex search on Python's AST.

Eclipse has also an excellent and easy-to-use debugger.
Reply all
Reply to author
Forward
0 new messages