Module nntplib
[hide private]
[frames] | no frames]

Module nntplib

An NNTP client class based on RFC 977: Network News Transfer Protocol.

Example:

>>> from nntplib import NNTP
>>> s = NNTP('news')
>>> resp, count, first, last, name = s.group('comp.lang.python')
>>> print 'Group', name, 'has', count, 'articles, range', first, 'to', last
Group comp.lang.python has 51 articles, range 5770 to 5821
>>> resp, subs = s.xhdr('subject', first + '-' + last)
>>> resp = s.quit()
>>>

Here 'resp' is the server response line. Error responses are turned into exceptions.

To post an article from a file: >>> f = open(filename, 'r') # file containing article, including header >>> resp = s.post(f) >>>

For descriptions of all methods, read the comments in the code below. Note that all arguments and return values representing article numbers are strings, not numbers, since they are rarely used for calculations.

Classes [hide private]
NNTPError
Base class for all nntplib exceptions
NNTPReplyError
Unexpected [123]xx reply
NNTPTemporaryError
4xx errors
NNTPPermanentError
5xx errors
NNTPProtocolError
Response does not begin with [1-5]
NNTPDataError
Error in response data
error_reply
Unexpected [123]xx reply
error_temp
4xx errors
error_perm
5xx errors
error_proto
Response does not begin with [1-5]
error_data
Error in response data
NNTP
Variables [hide private]
  NNTP_PORT = 119
  LONGRESP = ['100', '215', '220', '221', '222', '224', '230', '...
  CRLF = '\r\n'

Imports: re, socket


Variables Details [hide private]

LONGRESP

Value:
['100', '215', '220', '221', '222', '224', '230', '231', '282']