15.04.2013 Views

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

17.3.3. <strong>Python</strong> and NNTP<br />

Based on your experience with <strong>Python</strong> and FTP above, you can probably guess that there is an nntplib<br />

and an nntplib.NNTP class that you need to instantiate, and you would be right. As with FTP, all we need<br />

to do is to import that <strong>Python</strong> module and make the appropriate calls in <strong>Python</strong>. So let us review the<br />

protocol briefly:<br />

1.<br />

2.<br />

3.<br />

4.<br />

Connect to server<br />

Log in (if applicable)<br />

Make service request(s)<br />

Quit<br />

Look somewhat familiar? It should, because it's practically a carbon copy of the FTP protocol. The only<br />

change is that the login step is optional, depending on how an NNTP server is configured.<br />

Here is some <strong>Python</strong> pseudocode to get started:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!