News for hackers. Stuff that matters.
Re:Show HN: Python Source Code Refactoring Toolkit via AST by erezsh on Tuesday August 03, 2021 @05:45AM (#28047286)
I actually have a prototype of something like that, built on top of Lark. It's still far from being complete or user friendly, but I'm already successfully transpiling a subset of Python to Javascript.

It still needs a lot of handholding, but at the same time I get to use gems like -

    ... = TemplateTranslator({
    'isinstance($a, str)': "typeof($a) == 'string'",
    'isinstance($a, bool)': "typeof($a) == 'boolean'",
    'len($a)': '$a.length',
    'str($a)': '$a.toString()',
    'getattr($a, $b)': '$a and $a[$b]',
    'getattr($a, $b, $c)': '($a and $a[$b]) or $c',
    'hasattr($a, $b)': '$b in $a',
    '$a.join($b)': '$b.join($a)',
    ... })
Re:Show HN: Python Source Code Refactoring Toolkit via AST by bmc7505 on Sunday August 08, 2021 @12:39AM (#28104254)
Nice! I like the syntax, this reminds me of the structural search and replace feature from IntelliJ IDEA. Is this the project you were referring to?

https://github.com/erezsh/py2js