【发布时间】:2011-09-17 04:47:38
【问题描述】:
使用解释器模式,from gasp import * 会运行,但是当我将它放在脚本中时它不会。我直接从How to Think Like a Computer Scientist: Learning with Python 的第 4 章复制这个(在标题 4.11. GASP 下)。
脚本:
from gasp import *
begin_graphics()
Circle((200, 200), 60)
Line((100, 400), (580, 200))
Box((400, 350), 120, 100)
update_when('key_pressed')
end_graphics()
终端:
ben@ubuntu:~$ python '/home/ben/Documents/Python/gasp.py'
Traceback (most recent call last):
File "/home/ben/Documents/Python/gasp.py", line 1, in <module>
from gasp import *
File "/home/ben/Documents/Python/gasp.py", line 3, in <module>
begin_graphics()
NameError: name 'begin_graphics' is not defined
【问题讨论】:
-
+1 用于在不被询问的情况下包含您的第一个问题的完整回溯,因此实际上为我们提供了足够的信息来调试您的问题。