a question

tiissa tiissa at nonfree.fr
Sun Jul 3 05:19:45 EDT 2005


Xinyue Ye wrote:
> when I type sys.ps2 after import sys,
> I got the message like:
> Traceback (most recent call last):
>  File "<pyshell#10>", line 1, in -toplevel-
>   sys.ps2
> AttributeError: 'module' object has no attribute 'ps2'
> why does it happen?


sys.ps2 is defined in an interactive session only as precised in the doc 
[1]:


$ python
Python 2.3.5 (#2, May 29 2005, 00:34:43)
[GCC 3.3.6 (Debian 1:3.3.6-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys
 >>> print sys.ps2
...
 >>>


compared to:


$ cat ps2.py
import sys
print sys.ps2

$ python ps2.py
Traceback (most recent call last):
   File "ps2.py", line 2, in ?
     print sys.ps2
AttributeError: 'module' object has no attribute 'ps2'
$


[1] http://docs.python.org/lib/module-sys.html



More information about the Python-list mailing list