看到的一个有趣的 Open Source 项目(Brython), 虽然我觉得没什么实用性~ XD
不过, 既然是蛇年, 就让 浏览器 也 蛇化 吧~
Brython 的说明:
Brython的目标是用Python取代JavaScript,使Python成为web浏览器的脚本语言。
此项目载入一个 js 文件, 然后就可以用 Python 语法来操作 DOM、AJAX… 等等的事情. (写在 里面)
说明文件: Brython document,
下述范例取自此篇:
Brython Syntax 说明: Brython Syntax
link1 = A(\'Brython\', href=\'http://www.brython.info\')
link2 = A(B(\'Python\'), href=\'http://www.python.org\')
link = A()
link <= B(\'connexion\')
link.href = \'http://example.com\'
req = ajax()
req.on_complete = on_complete
req.set_timeout(timeout, err_msg)
req.open(\'POST\', url, True)
req.set_header(\'content-type\', \'application/x-www-form-urlencoded\')
req.send(data)
local_storage[\'foo\'] = \'bar\'
log(local_storage[\'foo\'])
del local_storage[\'foo\']
log(local_storage[\'foo\']) # prints None
库的套件可见: Brython – Compiling and running
这边有很多必须的 Library, 在这边列一些应用类的.
py2js.js
: does the conversion between the tokens and the Javascript codepy_dom.js
: interaction with the HTML document (DOM)py_ajax.js
: Ajax implementationpy_local_storage.js
: implementation of the HTML5 local storagepy_svg.py
: SVG support (vector graphics)by Tsung under CC-by-sa