我想用
IronPython in the browser
<script src="http://gestalt.ironpython.net/dlr-latest.js" type="text/javascript">
</script>
...
<script type="application/python" src="test.py" defer="true"></script>
<script type="application/python">
import test
test.Hello()
</script>
import语句似乎运行成功(如果test.py不存在,它将失败)。但是,它似乎没有加载文件的内容。test.py包含以下代码:
document.testing1.innerHTML = 'Hello from test.py'
def Hello():
window.Alert('Hello from test.py')
实际上,test.py中的内容似乎没有任何区别。它不会抱怨语法错误。
在您可以从浏览器中访问的IronPython控制台中,也会出现同样的问题:
>>> import test
>>> dir(test)
['__builtins__', '__doc__', '__file__', '__name__', '__package__']
>>> test.Hello()
Traceback (most recent call last):
at <module> in <string>, line 1
at <module> in <string>, line 0
AttributeError: 'module' object has no attribute 'Hello'
更新: