String Formatting
See original GitHub issueI think string formatting will be a very big issue for pyscript in the next months/years. Maybe a generic solution similar to <pre> </pre>
could be possible? I’ve seen a similar solution in a syntax highlighting library some time ago (<code> </code>
). For now, the following code returns an error(in both Firefox and Chrome):
for r in range(0xff):
color="#%02x29%02x" % (r,r)
printdata = "<font color=\"%s\">sodjf</font>" % color
print(printdata)
JsException(PythonError: Traceback (most recent call last): File “/lib/python3.10/site-packages/_pyodide/_base.py”, line 429, in eval_code .run(globals, locals) File “/lib/python3.10/site-packages/_pyodide/_base.py”, line 300, in run coroutine = eval(self.code, globals, locals) File “”, line 5, in TypeError: not all arguments converted during string formatting )
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Python String Formatting Best Practices
Formatted string literals are a Python parser feature that converts f-strings into a series of string constants and expressions. They then get joined...
Read more >Python String format() Method - W3Schools
The format() method formats the specified value(s) and insert them inside the string's placeholder. The placeholder is defined using curly brackets: {}.
Read more >String formatting in Python - GeeksforGeeks
String formatting is the process of infusing things in the string dynamically and presenting the string. There are four different ways to ...
Read more >7. Input and Output — Python 3.11.1 documentation
Formatted string literals (also called f-strings for short) let you include the value of Python expressions inside a string by prefixing the string...
Read more >Standard numeric format strings | Microsoft Learn
In this article. Standard format specifiers; Use standard numeric format strings; Currency format specifier (C); Decimal format specifier (D) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
same
I believe this is fixed by #684 - at least, the final example posted above does correctly work.
Conversations around escaping HTML-relevant characters in PyScript source are ongoing in #735 - but this specific issue is resolved.