Python nntplib %u2014 NNTP protocol client














































Python nntplib %u2014 NNTP protocol client



This module defines the class NNTP which implements the client-side of the NNTP protocol. It can be used to implement a newsreader or poster, or automated news processors. For more information on NNTP (Network News Transfer Protocol).
Here is an example of how to use it. To list some statistics about a newsgroup and print the subjects of the last 10 articles:


The module itself defines the following items:

class nntplib.NNTP(host[, port [, user[, password [, readermode] [, usenetrc]]]])

Return a new instance of the NNTP class, representing a connection to the NNTP server running on the host, listening at the port. The default port is 119. If the optional user and password are provided, or if suitable credentials are present  /.netrc and the optional flag usenetrc is true (the default), the AUTHINFO USER and AUTHINFO PASS commands are used to identify and authenticate the user to the server. If the optional flag reader mode is true, then a mode reader command is sent before authentication is performed. Reader mode is sometimes necessary if you are connecting to an NNTP server on the local machine and intend to call reader-specific commands, such as group. If you get unexpected s, you might need to set reader modereader mode defaults to. usenetrc defaults to True.

Changed in version 2.4: usenetrc argument added.

exception nntplib.NNTPError

Derived from the standard exception, this is the base class for all exceptions raised by the module.

exception nntplib.NNTPReplyError

Exception raised when an unexpected reply is received from the server. For backward compatibility, the exception is equivalent to this class.

exception nntplib.NNTPTemporaryError

Exception raised when an error code in the range 400%u2013499 is received. For backward compatibility, the exception is equivalent to this class.

exception nntplib.NNTPPermanentError

Exception raised when an error code in the range 500%u2013599 is received. For backward compatibility, the exception is equivalent to this class.

exception nntplib.NNTPProtocolError

Exception raised when a reply is received from the server that does not begin with a digit in the range 1%u20135. For backward compatibility, the exception is equivalent to this class.

exception nntplib.NNTPDataError

Exception raised when there is some error in the response data. For backward compatibility, the exception is equivalent to this class.




Comments