Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 1 | \section{Standard Module \sectcode{nntplib}} |
Guido van Rossum | a12ef94 | 1995-02-27 17:53:25 +0000 | [diff] [blame] | 2 | \stmodindex{nntplib} |
Guido van Rossum | 8675115 | 1995-02-28 17:14:32 +0000 | [diff] [blame] | 3 | |
| 4 | \renewcommand{\indexsubitem}{(in module nntplib)} |
| 5 | |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 6 | This module defines the class \code{NNTP} which implements the client |
| 7 | side of the NNTP protocol. It can be used to implement a news reader |
| 8 | or poster, or automated news processors. For more information on NNTP |
| 9 | (Network News Transfer Protocol), see Internet RFC 977. |
| 10 | |
| 11 | Due to time constraints, the documentation for this module could not |
| 12 | be completed for this release of the Python documentation. Here are |
| 13 | two small examples of how it can be used. |
| 14 | |
| 15 | To list some statistics about a newsgroup and print the subjects of |
| 16 | the 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 |
| 22 | Group 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 | ... |
| 26 | 3792 Re: Removing elements from a list while iterating... |
| 27 | 3793 Re: Who likes Info files? |
| 28 | 3794 Emacs and doc strings |
| 29 | 3795 a few questions about the Mac implementation |
| 30 | 3796 Re: executable python scripts |
| 31 | 3797 Re: executable python scripts |
| 32 | 3798 Re: a few questions about the Mac implementation |
| 33 | 3799 Re: PROPOSAL: A Generic Python Object Interface for Python C Modules |
| 34 | 3802 Re: executable python scripts |
| 35 | 3803 Re: POSIX wait and SIGCHLD |
| 36 | >>> s.quit() |
| 37 | '205 news.cwi.nl closing connection. Goodbye.' |
| 38 | >>> |
| 39 | \end{verbatim} |
| 40 | |
| 41 | To post an article from a file (this assumes that the article has |
| 42 | valid 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} |