ben ben - 1 year ago 117
Python Question

Difficulty Importing GASP Using Script

Using interpreter mode,

from gasp import *
runs, but when I place it in a script it doesn't. I'm copying this straight from chapter 4 of How to Think Like a Computer Scientist: Learning with Python (under heading 4.11. GASP).


from gasp import *


Circle((200, 200), 60)
Line((100, 400), (580, 200))
Box((400, 350), 120, 100)



ben@ubuntu:~$ python '/home/ben/Documents/Python/'
Traceback (most recent call last):
File "/home/ben/Documents/Python/", line 1, in <module>
from gasp import *
File "/home/ben/Documents/Python/", line 3, in <module>
NameError: name 'begin_graphics' is not defined

agf agf
Answer Source

Rename your script. You're hiding the real gasp module:

ben@ubuntu:~$ python '/home/ben/Documents/Python/' 

When you

from gasp import *

it's trying to import itself because you called it

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download