Transcrypt icon indicating copy to clipboard operation
Transcrypt copied to clipboard

String formatting mini language in fstrings broken

Open JdeH opened this issue 4 years ago • 3 comments

Parser change?

JdeH avatar Jun 20 '21 16:06 JdeH

I may be misreading this issue, but if it is helpful, I just transcoded the Jython minilanguage parser to JS last week. Happy to contribute it to the code if you need a parser.

My work project needed a full-featured, fully-compliant parser, and I figured since Jython has been around 20 years, it probably has had time to get it right. Plus Java is close enough to JS syntactically that it wasn't terrible.

doconix avatar Jun 20 '21 20:06 doconix

Hi, good to hear from you! And thanks, this may be interesting, not sure yet. B.T.W. I meant the recent change to the CPython parser. CPython uses a different parsing principle now, that may have some unforeseen consequences.

JdeH avatar Jul 02 '21 17:07 JdeH

I think I just ran into this one trying to format a number with commas.

This Python code :

f'{1000000:,}'

in JS converts to:

'{}'.format (1000000)

JennaSys avatar Sep 30 '22 20:09 JennaSys