a question

X

Xinyue Ye

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?
 
S

Steven D'Aprano

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?

It works for me.
'... '

Can you cut and past the relevant lines from your interactive session?
 
T

tiissa

Xinyue said:
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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,260
Messages
2,571,308
Members
47,956
Latest member
AmeeBerger

Latest Threads

Top