flexxui / pscript

Python to JavaScript compiler
http://pscript.readthedocs.io
BSD 2-Clause "Simplified" License
260 stars 25 forks source link

python2.7, pscript and async/await statement, is it a bug or a limitation ? #29

Closed manatlan closed 6 years ago

manatlan commented 6 years ago

Hi,

If i made a python class with async/await statements, it translates great to JS when I use python3. But it can't translate to JS when I use python2.7 :

  File "<string>", line 9
    async def inc(self,nb=1):
            ^
SyntaxError: invalid syntax

I known that async/await are py3 features. But when it comes to render to JS (which support async/await) ; is it possible to bypass this limitation (to be able to use async/await in JS) ?

thanks in advance

almarklein commented 6 years ago

No. PScript uses Python's buildin parser to generate the AST (abstract syntax tree) which is then used to generate the JavaScript. In other words, your code must be valid Python, subject to the used Python interpreter.