ngwattcos/react-python ↗
Created Jan 8, 2021 · View the ngwattcos/react-python repository page
A Python-like syntax that compiles down into JSX.
Want this for your repo?
Render a free sample of any GitHub repo in seconds.
Contributors
2
Lines of Code
264
From
Oct 10, 2020
To
Dec 30, 2020
About ngwattcos/react-python
React-Python is an npm wrapper for pythonxyc, a compiler that translates Python-like code into React JSX. The project provides a bridge between Python's familiar syntax and JavaScript's React ecosystem, allowing developers to write components using a Python-inspired language that compiles down to working JSX code.
The compiler supports a substantial subset of Python features including variables, functions, control flow statements, operators, and importantly, JSX expressions as first-class values. It uses custom syntax elements like @let, @const, and @end to handle JavaScript variable declaration and scoping, since Python relies on indentation while the project chose explicit delimiters. The language includes built-in support for importing and exporting modules using a hybrid JavaScript-Python syntax, as well as functional programming helpers like map, filter, and reduce on arrays.
The project targets React developers who prefer Python's syntax style and includes tooling for file watching and compilation integration into development workflows. Notable limitations include lack of support for classes (though they're planned), tuples, and negation operators, though workarounds exist for most of these. The compiler performs AST transformation and translation in two stages, handling special cases like converting print statements to console.log and translating Python's range and list slicing into JavaScript equivalents.
