[Tutor] Same code has different result

Andreas Perstinger andipersti at gmail.com
Sun Feb 12 16:13:01 CET 2012

On Sun, 12 Feb 2012 21:31:57 +0800
daedae11 <daedae11 at 126.com> wrote:

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

It seems that the connection is closed if you need more than about 6-7 seconds (on my computer) to type the third line.

>From the source of "nntplib.py":

def getline(self):
    """Internal: return one line from the server, stripping CRLF.
    Raise EOFError if the connection is closed."""

Bye, Andreas

More information about the Tutor mailing list