Brython: passing arguments
The documentation doesn’t go into this too well, but its kinda important I think for reusable bython scripts. The following is an examples of how to set args in the script tag and reading them in the code.
It should be note, that just like with the python sys.argv, the first argument is the code that is called, so your data is in index 1 and more.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Brython passing arguments</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js"></script>
</head>
<body>
<div id="test1"></div>
<script type="text/python" args="45 two 9">
from browser import document
import sys
print(sys.argv[1])
print(sys.argv[2])
print(sys.argv[3])
</script>
</body>
</html>