[Tutor] Same code has different result

daedae11 daedae11 at 126.com
Sun Feb 12 14:31:57 CET 2012


The code is:
from nntplib import NNTP
s = NNTP('news.gmane.org')
resp, count, first, last, name = s.group('gmane.comp.python.committers')
print 'Group', name, 'has', count, 'articles, range', first, 'to', last
resp, subs = s.xhdr('subject', first + '-' + last)
for id, sub in subs[-10:]:
    print id, sub
s.quit()

When I write it into a script, it can execute normally. However, when I input it in interpreter line by line, I got the follow error when I execute the third sentence. What's the matter?

>>> s = NNTP('news.gmane.org')
>>> resp, count, first, last, name = s.group('gmane.comp.python.committers')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Python27\lib\nntplib.py", line 345, in group
    resp = self.shortcmd('GROUP ' + name)
  File "D:\Python27\lib\nntplib.py", line 259, in shortcmd
    return self.getresp()
  File "D:\Python27\lib\nntplib.py", line 214, in getresp
    resp = self.getline()
  File "D:\Python27\lib\nntplib.py", line 206, in getline
    if not line: raise EOFError
EOFError






daedae11
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120212/ba715896/attachment-0001.html>


More information about the Tutor mailing list