News for hackers. Stuff that matters.
Re:Show HN: Python Source Code Refactoring Toolkit via AST by dreamer7 on Monday August 02, 2021 @12:56AM (#28033045)
Would this be a good tool to attempt simple transpiling of typescript code to python?

For my use-cases, not much changes between the two -

1. Replace opening and closing braces with colon.

2. Remove semi colons

3. Replace function with def

4. Remove type definitions

5. Replace array manipulation functions with python equivalents.

6. Remove tokens like const, let and var

Re:Show HN: Python Source Code Refactoring Toolkit via AST by erezsh on Tuesday August 03, 2021 @05:32AM (#28047235)
It's a good start, but there are many other differences. a[i] can mean getattr (but usually not), and can throw a KeyError. Similarly, a.b may return null if it doesn't exist, while in Python it will throw an AttributeError. You might need to add uses of global or nonlocal. And there are a lot of other small details.

However, I think it will be much easier than translating the other way around :)