pythonpython-2.7gasp

Why does GASP work properly only when induced in terminal?


I typed the following commands into terminal:

br@wind:~$ python
Python 2.7.3 (default, Aug  1 2012, 05:16:07) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gasp import *
>>> begin_graphics()
>>> Closed.
br@wind:~$ touch gasp.py
br@wind:~$ echo "from gasp import *" >>  gasp.py
br@wind:~$ echo "begin_graphics()" >> gasp.py
br@wind:~$ cat gasp.py 
from gasp import *
begin_graphics()
br@wind:~$ python gasp.py
Traceback (most recent call last):
  File "gasp.py", line 1, in <module>
    from gasp import *
  File "/home/br/gasp.py", line 2, in <module>
    begin_graphics()
NameError: name 'begin_graphics' is not defined

Why does GASP run only when I type code directly in python shell, but it does not work when I execute a python script?


Solution

  • common mistake, don't name your program with the same name as the library you're using.