インタープリターモードを使用するとfrom gasp import *
実行されますが、スクリプトに配置すると実行されません。How to Think Like a Computer Scientist: Learning with Python (見出し 4.11. GASP の下)の第 4 章からこれをそのままコピーしています。
脚本:
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