Foundations of Python Network Programming 144
Foundations of Python Network Programming | |
author | John Goerzen |
pages | 500 |
publisher | Apress |
rating | 9 of 10 |
reviewer | Sarusa |
ISBN | 1590593715 |
summary | If you program in Python, and you want to write Internet applications, you need this book. |
First of all, 'Network' means 'Internet.' Everything in the book concerns protocols running over IP, which is almost anything useful these days. That said, this is a lot of ground to cover -- there's FTP, HTTP, POP3, IMAP, DNS, a veritable explosion of acronyms, and this book does a great job of hitting all the ones you're likely to need.
Foundations assumes you already know Python, but nothing about network programming. The first 100 pages covers the basics of IP, TCP, UDP, sockets and ports, server vs. daemon, clients, DNS, and more advanced topics like broadcast and IPv6. And in case you already know all that, how Python deals with them. This is the only part of the book you will probably read in order. After that you pick what you need.
Find a topic you need to know how to deal with, such as using XML-RPC, and locate the appropriate section of the book. There he'll cover the basics of the topic, show you how to use the correct Python module(s) to implement it, explain any gotchas (this is key!), and write a short but functional application or two that uses it. I'm not sure why this book isn't called 'Practical Python Network Programming.' It's eminently Practical. It won't make your heart race, but it tells you exactly what you need to get the job done.
All this information is out there to find for free, but having it all collected and summarized is worth every penny. And the real value is having the edge conditions and not-so-obvious practical details explained by someone who's obviously used this stuff in the field. Python and its excellent libraries make Internet tasks relatively easy, but it's even easier with some expert help, and the libraries assume you already know what you're trying to do. For example, if you're doing a DNS.Request() record query and using a DNS.Type.ANY, it (for good reason) returns information cached by your local servers, which may be incomplete. If you really need all the records you need to skip your local servers and issue a query to the name server for the domain. This is isn't hard; you just have to know what's going on. Or do you know which exceptions can get raised if you're using urllib to fetch web pages? It's here. Exception handling is not neglected.
So you know what you're getting, here's a laundry list of topics: IP, TCP, UDP, sockets, timeouts, network data formats, inetd/xinetd, syslog, DNS, IPv6, broadcast, binding to specific addresses, poll and select, writing a web client, SSL, parsing HTML and XHTML, XML and XML-RPC, email composition and decoding, MIME, SMTP, POP, IMAP, FTP, MySQL/PostgreSQL/zxJDBC (though you won't learn SQL), HTTP and XML-RPC servers, CGI, and mod_python. As a bonus you get some chapters on forking and threading (for writing servers) and handling asynchronous communication in general.
Just to find something to complain about churlishly, I wish Goerzen had managed to do all this and make it scintillatingly brilliant and witty from cover to cover (all 500 pages); perhaps dropping juicy bon mots of gossip from the Debian project. And while I'm at it I'd like a pony. No, seriously. If you program in Python, intend to do anything Internet related, and aren't already a Python networking god, you need Foundations of Python Network Programming. In terms of 'hours I could have saved if only I had this book sooner' it would have paid for itself many times over.
You can purchase Foundations of Python Network Programming from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
As the author says... (Score:5, Insightful)
Is it? If you are, as the author says, someone familiar with Python but you have no clue about network concepts or programming, perhaps this book isn't for you. The first 100 pages or so are all intro to networking; after that, you have specific Python networking programming topics. Perhaps you'd be better suited with a networking book and then this book (sans the first 100 pages).
I've read a few books on programming languages and when they decide that the reader needs an intro to something, they usually provide pretty poor coverage of that topic. You end up being lost after you get done with the intro section. I did this when I was learning some encryption programming... before I could start actually writing code that deals with encryption, I needed a solid base. Instead of trying to teach me all I needed to know, the reference I was using pointed me at the industry's best encryption and security books and authors (like Bruce Schneier).
Disclaimer: Not having read this particular book, maybe this one is different. I don't know.
Re:Amazon (Score:5, Insightful)
Re:As the author says... (Score:3, Insightful)
That is why all the older Oreilly books are so good. No padding. No bullshit. The books were about what the cover said they were about, no less and no more. All meat.
Re:Amazon (Score:4, Insightful)
Look: Programming in Perl is Simply Irresponsible! (Score:2, Insightful)
If you choose to program in Perl, the poor suckers who are going to have to read, maintain, clean up and modify the code you wrote will hate your guts.
Programming languages should be designed primarily for PEOPLE to read, understand, write and maintain reliably, and only incidentally for computers to interpret and execute.
Perl goes against every rule in the book about readability, simplicity, learnability, maintainability, integrity, responsibility to the community and style. And for no good reason!
The naively celebrated fact that Perl always has 2 dozen special case syntaxes, idioms, implicit rules and perverted styles to write the same thing, adds absolutely no power to the language whatsoever, and just makes it harder to read, write and maintain.
Even if you're just writing "throw away" Perl code, not working on anything important enough to reuse or share with other people, you're still crippling yourself with lazy bad habits that will doom you when you get a real job or start working on a project worth sharing with other people.
-Don
Every Perl programmer should switch to Python. (Score:5, Insightful)
At least, for a month or so.
Knowing multiple languages increases your value as a programmer quadratically. I like to think that languages follow a square law. By doubling the number of languages you know, you quadruple your total skill and marketability as a programmer.
I've done significant stuff in both languages and there are definitely tasks where Python is better -- for example, command-and-control, super-high-level types of apps, which coordinate large systems of smaller programs. And Perl is vastly superior in other situations, such as processing enormous wads of data and formatting output. I've even written hybrid programs where Python and Perl code intertwine.
Step outside your box. You don't have to love the language you're learning, but consider it an investment in yourself. Saving money sucks too, but it's still a good idea.
Have you tried Ruby? (Score:4, Insightful)
Ruby [ruby-lang.org] to Python. No indentation hassles with Ruby, for example. You'll also like the way Ruby does OO compared to Perl OO. More [rubyforge.org] Rubilicious [ruby-doc.org] links... [rubygarden.org]
Also, The Pragmatic Programmers [pragmaticprogrammer.com] have released a new edition of Programming Ruby that's a great intro and reference to the language - go buy it from their website.
Ruby: Because I can't wait around for Perl 6 to get finished
Re:As the author says... (Score:5, Insightful)
Having read the book, I understand socket programming, general network programming, and could probably design and implement my own application protocol -- badly, of course, but still... Could I have done this prior to reading this book? No. Did this book make it easy to pick up the necessary background, as well as make it easy to pick up the specifics of network programming in Python? Yes.
This is a great book, and is a must-have for Python programmers.
Re:Amazon (Score:1, Insightful)
Try starting a small company that makes Apple clone hardware and see if Apple keeps you from doing something that you want.
Re:Amazon (Score:1, Insightful)
I don't know of Apple or amazon.com trying to keep me from doing something I want or pay for something that should be free, so I'm not all that fussed.
Unless of course you want to use something like an affiliate program or 1-click ordering, which Amazon has patented.
Amazon is still on my shitlist, but the great thing about the internet is you can "shop" at amazon and then click-click, buy your book somewhere else, with a clear conscience.
Re:Look, I program in Perl (Score:3, Insightful)
Re:Easiest review to skip (Score:5, Insightful)
Re:Every Perl programmer should switch to Python. (Score:3, Insightful)
Different syntax and different libraries will open your mind a little. But when a language encourages (or forces) you to think differently, that's where your "square law" starts to kick in.
Re:Look, I program in Perl (Score:3, Insightful)
Encryption Programming and Canned Libraries (Score:3, Insightful)
If you're a "$LANGUAGE Programmer"... (Score:4, Insightful)
As the parent post says, knowing multiple languages is good. One of my pet annoyances is hearing people describe themselves as a programmer for a specific language -- there are many more out there, and to say you only do one speaks volumes about the lack of breadth of experience you posess.
And don't just stick with imperative object-oriented languages. Try a few declarative languages, like Haskell (functional) or Prolog (logic). Yes, getting your head around them is hard. But you'll be glad you did.
Disclaimer: I'm a student doing an MSc in Computer Science, and by lines of code, most of what I wrote in the last twelve months was Perl, and was completely unrelated to my thesis