blob: e5ee97de2ed51264d98b0f313659c83d111c9c10 [file] [log] [blame]
Guido van Rossum470be141995-03-17 16:07:09 +00001\section{Standard Module \sectcode{nntplib}}
Guido van Rossuma12ef941995-02-27 17:53:25 +00002\stmodindex{nntplib}
Guido van Rossum86751151995-02-28 17:14:32 +00003
4\renewcommand{\indexsubitem}{(in module nntplib)}
5
Guido van Rossumcca8d2b1995-03-22 15:48:46 +00006This module defines the class \code{NNTP} which implements the client
7side of the NNTP protocol. It can be used to implement a news reader
8or poster, or automated news processors. For more information on NNTP
9(Network News Transfer Protocol), see Internet RFC 977.
10
11Due to time constraints, the documentation for this module could not
12be completed for this release of the Python documentation. Here are
13two small examples of how it can be used.
14
15To list some statistics about a newsgroup and print the subjects of
16the last 10 articles:
17
18\begin{verbatim}
19>>> s = NNTP('news.cwi.nl')
20>>> resp, count, first, last, name = s.group('comp.lang.python')
21>>> print 'Group', name, 'has', count, 'articles, range', first, 'to', last
22Group comp.lang.python has 59 articles, range 3742 to 3803
23>>> resp, subs = s.xhdr('subject', first + '-' + last)
24>>> for id, sub in subs[-10:]: print id, sub
25...
263792 Re: Removing elements from a list while iterating...
273793 Re: Who likes Info files?
283794 Emacs and doc strings
293795 a few questions about the Mac implementation
303796 Re: executable python scripts
313797 Re: executable python scripts
323798 Re: a few questions about the Mac implementation
333799 Re: PROPOSAL: A Generic Python Object Interface for Python C Modules
343802 Re: executable python scripts
353803 Re: POSIX wait and SIGCHLD
36>>> s.quit()
37'205 news.cwi.nl closing connection. Goodbye.'
38>>>
39\end{verbatim}
40
41To post an article from a file (this assumes that the article has
42valid headers):
43
44\begin{verbatim}
45>>> s = NNTP('news.cwi.nl')
46>>> f = open('/tmp/article')
47>>> s.post(f)
48'240 Article posted successfully.'
49>>> s.quit()
50'205 news.cwi.nl closing connection. Goodbye.'
51>>>
52\end{verbatim}