【问题标题】:Why does GASP work properly only when induced in terminal?为什么 GASP 只有在终端诱导时才能正常工作?
【发布时间】:2013-05-16 12:50:35
【问题描述】:

我在终端中输入了以下命令:

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

为什么 GASP 只在我直接在 python shell 中键入代码时运行,但在我执行 python 脚本时它不起作用?

【问题讨论】:

    标签: python python-2.7 gasp


    【解决方案1】:

    常见错误,不要使用与您正在使用的库相同的名称来命名您的程序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-26
      • 1970-01-01
      • 2012-11-18
      • 2020-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多