r/HTML • u/[deleted] • May 12 '24
Question How do I fix "SyntaxError: '(' was never closed"?
I am writing a pyxel file (python retro game engine file) and turning it into an html. When I run it as an html file, I get this error:
Traceback (most recent call last):
File "/lib/python311.zip/_pyodide/_base.py", line 493, in eval_code
CodeRunner(
File "/lib/python311.zip/_pyodide/_base.py", line 267, in __init__
self.ast = next(self._gen)
^^^^^^^^^^^^^^^
File "/lib/python311.zip/_pyodide/_base.py", line 145, in _parse_and_compile_gen
mod = compile(source, filename, mode, flags | ast.PyCF_ONLY_AST)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 20
pyxel.text(0,0,
^
SyntaxError: '(' was never closedThis doesn't make sense to me because in my code, I closed (. What is happening here? Here's my code for reference:
<script src="https://cdn.jsdelivr.net/gh/kitao/pyxel/wasm/pyxel.js"></script>
<pyxel-run script="
import pyxel
import dataclasses as dataclass
SCREEN_WIDTH = 160
SCREEN_HEIGHT = 100
class Game:
def __init__(self):
pyxel.init(SCREEN_WIDTH, SCREEN_HEIGHT, fps = 60)
def draw(self):
pyxel.text(0,0, "hello world", 0)
Game()
"></pyxel-run>
2
Upvotes
1
u/ZipperJJ Expert May 12 '24
It doesn't seem to like double quotes in pyxel.text. Switch to single quotes, it doesn't throw an error.