Re: Aha: How to find patterns in python parse trees

2023-05-10 Thread Edward K. Ream
On Tuesday, May 9, 2023 at 9:32:54 AM UTC-5 tbp1...@gmail.com wrote: There has been many words written about how important static typing is, and how therefore languages like Python cannot really be good production languages. To the contrary, I have read that only say 10% of bugs in actual

Re: Aha: How to find patterns in python parse trees

2023-05-09 Thread Thomas Passin
On Tuesday, May 9, 2023 at 7:54:48 AM UTC-4 Edward K. Ream wrote: On Monday, May 8, 2023 at 8:16:08 AM UTC-5 Edward K. Ream wrote: Once the technical problem disappeared it became clear that static checks of Leo's code are not likely to be of great value! There has been many words written

Re: Aha: How to find patterns in python parse trees

2023-05-09 Thread Edward K. Ream
On Monday, May 8, 2023 at 8:16:08 AM UTC-5 Edward K. Ream wrote: Yesterday I discovered a dead simple *design* pattern for finding *code* patterns in python parse trees. The *AnnotationsTraverser.**test_annotation* method revealed several surprising annotations. PR #3319

Re: Aha: How to find patterns in python parse trees

2023-05-08 Thread Edward K. Ream
On Mon, May 8, 2023 at 8:42 AM Thomas Passin wrote: there has been theoretical and (somewhat?) practical work on regular > expressions for trees. E.g., > > Implementing Regular Tree Expressions > (very > tough going) > Tregex,

Re: Aha: How to find patterns in python parse trees

2023-05-08 Thread Thomas Passin
I'm not surprised by this. I found the same thing in developing my bookmarks manager. Conceptually the structure of the bookmarks collection is tree-like, but it can be much easier to flatten that structure into text and use string methods on the flattened structure. OTOH, there has been

Aha: How to find patterns in python parse trees

2023-05-08 Thread Edward K. Ream
Yesterday I discovered a dead simple *design* pattern for finding *code* patterns in python parse trees. This pattern is a milestone. It changes forever how I'll use python's ast module. Old techniques now seem like trying to swat flies with a