TCP/IP protocols

John Mitchell johnm at magnet.com
Fri Apr 14 19:01:09 EDT 2000


On Sat, 15 Apr 2000, Thomas Wouters wrote:

> On Fri, Apr 14, 2000 at 04:28:03PM -0600, Jeff Massung wrote:
> 
> > I'm new to Python programming, but am very experienced in C/C++. Could
> > someone point me to a good reference for TCP/IP programming with Python
> > (pdf, book, anything :]) thanks.

> If you're looking for some higher-level programming, see libraries like
> httplib, ftplib, telnetlib, urllib, SocketServer, *HTTPServer, etc.

These are actually just two libraries: client-side (urllib handles FTP,
HTTP, local files), plus server-side (Socket/HTTPServer).

For example, to fetch a web page is this:

import urllib
data = urllib.urlopen('http://www.magnet.com/')

To get some information out, it's much more complicated: 3 lines:

import htmllib, formatter
p.feed(data)
p.title
# =>  'Magnet Interactive Communications'


Show this to your local Java weenie.  He'll whine like a stuck pig!


> Documentation for all these modules comes with the python source (in the
> Doc/lib/ directory) in TeX format, with most binary distributions in some
> form or another, or can be downloaded or browsed online at
> http://www.python.org/doc/lib/ (There's an entire chapter, 11, dedicated to
> 'Internet Protocols and Support'.)

oh yeah.  But the above is your 60-second introduction.


- j






More information about the Python-list mailing list