Foundations of Python Network Programming
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.
The book is cheaper through Amazon
"You're older than you've ever been, and now you're even older."
Another good Python network resource: Twisted Matrix, a networking framework for Python.
For those interested in starting in network programming in Python, I'd recommend checking it out.
My UID is the product of 2 primes.
I liked this book a lot, but there are an awful lot of annoying typos. Also my binding broke after a week.
And I see no need to switch to Python. My question is: How easy is it to wrap your code in a library/module and call it your own so you can call it your way? When I tried Python, my first impression was that this was a really readable and relatively easy language to program in, but it just wasn't a Swiss-Army chain saw. You were doing things over and reinventing the wheel all the time. This might have been just me. I admit to being a bigot and a classic pig-headed perl person, but with the nightmare that is Perl6 on the horizon, I need to start considering alternatives.
Comparing it to Windows will be a moot point, since El Dorado is going to have a 40% larger code base than XP.
"All this information is out there to find for free, but having it all collected and summarized is worth every penny."
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.
I use Python to administer computers... lots and lots of computers. It runs on Macs, Windows, Linux and all variants of Unix. It's one of the most portable languages around.
I used to be a huge Linux buff (and still am when it comes to servers), but intelligent tools like Python make using Windows XP Home a much more fruitful and fun experience as I can actually get stuff done programmatically. Go Python developers and keep up the good work!!!
It also had a brief Python tutorial in it, but I kind of skipped over that, so I can't vouch for that part. The rest of the book will definitely teach you a bit about network programming, web/database programming, and things of that nature. For most of the /. programmers it might be pretty old hat since they were doing this stuff in the womb, but for unexperience programmers such as myself, I found it helpful.
Incidentally, Civilization IV is going to be moddable with Python
Save your wrists today - switch to Dvorak
http://groups.google.com/ groups?q=Foundations+of+Python+Network+Programming &hl=en&lr=&selm=mailman.3337.1095202643.5135.pytho n-announce-list%40python.org&rnum=1
Chris Williams clw7500nc@gmail.com
...and one of those ways is to use Python. No biggie.
Breakfast served all day!
For a minute there I really did think the title "Foundations of Python Network Programming" indicated that a new Python Network was being created for television and that they were laying the foundations and discussing what the programming schedule would be.
Seriously, no joke. And by the way, a Python Network would be beat the Game Show Network hands down !!!
"Whoever would overthrow the liberty of a nation must begin by subduing the freeness of speech."--Benjamin Franklin
Beats the shit out of Python IMHO. It's OO done right, very clean, very dynamic. Easy to extend using C, so you don't have to reinvent the wheel. Has a very friendly and helpful user base - ruby-talk@ruby-lang.org
Look it up.
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
Take a look and feel free: http://www.PieMenu.com
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.
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!
O.K. Why don't you start with listing a single specific?
I really think that if you're coming from Perl you'll prefer
Ruby to Python. No indentation hassles with Ruby, for example. You'll also like the way Ruby does OO compared to Perl OO. More Rubilicious links...
Also, The Pragmatic Programmers 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
I can't say enough good things about SWIG. It's an amazing piece of work that has saved me years of menial labor and enabled me to integrate all kinds of compex code into Python, from hairy C++ templates to third party Win32 libraries for which there is no source code. It works extremely well with Python, and many other languages too.
Here is the blurb from the web site www.swig.org:
SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is primarily used with common scripting languages such as Perl, Python, Tcl/Tk and Ruby, however the list of supported languages also includes non-scripting languages such as C#, Common Lisp (Allegro CL), Java, Modula-3 and OCAML. Also several interpreted and compiled Scheme implementations (Chicken, Guile, MzScheme) are supported. SWIG is most commonly used to create high-level interpreted or compiled programming environments, user interfaces, and as a tool for testing and prototyping C/C++ software. SWIG can also export its parse tree in the form of XML and Lisp s-expressions. SWIG may be freely used, distributed, and modified for commercial and non-commercial use.
-Don
Take a look and feel free: http://www.PieMenu.com
Hey everybody: What's wrong with Perl?
Nothing. Unless you want to write like you do C/C++ or shell scripting in Perl(that is what may people do).
If you follow the style guide and conventions, you will be able to write concise, elegant code in Perl. Hmmm... It's like English. You can write poetry or you can spew out illiterate gibberish. One has to invest some time in studying Perl. It grows on you.
S
Have you ever written a single line of code?
It's like maturbating in public and not cleaning up after yourself.
Yes! whenever I masturbate in public I always wipe it up afterwards! The cashier at the supermarket really appreciated that!
I thought so....
How would you play roguelikes with a Dvorak layout on a laptop, since movement keys are based on Qwerty?
Play Command HQ online
I don't use Python for much, but one of the primary reasons when I do is that a small, hacked together, uncommented python script is way easier to read months or years later than a similar Perl script or C source.
Play Command HQ online
I've written so many prototypes for other, usually less experienced, programmers to implement for release. I've learned always to write the comments first. Then I fill in working code. That discipline has also made me a better, more focused coder. Especially when I prototype in Perl, programming's encrypted Swiss Army Chainsaw ;).
--
make install -not war
Here's a good example, other than being used as mathametical operators, what are all uses of the following symbols in perl:
!@#$%^&*()?{}[]
Each of these symbols and combinations of these symbols have a special meaning in perl, which one can only know by either: memorizing, or looking them up. The beauty of python is that you don't have to memorize nearly as many special symbols to work with variables. I could give some specific examples, but I don't want to spend the time right now to read through perl documentation.
The first thing you get from a "solid base" of encryption knowledge is the concept that doing your own encryption algorithms except as an exercise is a really bad idea.... But that doesn't mean that you can write application programs that use standard libraries like OpenSSL without a solid understanding of what the encryption technology's doing - you really do want to be more than a script kiddie in this field.
Bill Stewart
New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
The usual way involves a pageful of obscure code, and having to use obtuse WSDL descriptor files and code generators to give you classes.
But, hey, python can generate classes and methods on the fly. So getting the temperature at zip code 90210 becomes a one-liner after some standard imports:
I'm not kidding; that line currently returns the floating point number 68.0.Note: you'll need to remove the extra space in the URL that the slashdot antilameness crud inserts. The full example is found in simpleWSDL.py in that package.
Nerd animosity towards documention runs deep. Mods didn't like my snarky review of the glowing review, but how is it a "Troll"? As usual, no replies disputing the logic or evidence. Another chance to comment missed by people who'd rather communicate with a machine than use it to communicate with another person.
--
make install -not war
I just glanced at your journal after being astonished by your arrogance and (likely unjustified) sense of elitism.
Conclusion: Tool.
If you consider yourself to be a $LANGUAGE programmer, then there's something wrong.
:-)
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
Pretend that something especially witty is here. Thanks.
Anonymous puny Coward, you found the geek definition of Troll in my journal, that obviously doesn't support that charge, and you just misspell it to try to insult me? I don't know about your "elitist" charge, but I am smart, and you are not. Keep your obnoxious gibbering to yourself, Anonymous fool Coward.
--
make install -not war
Mark Pilgrim pretty much got a special exception from apress to allow his book to be downloaded, IIRC.
90% of the book was written and freely available on his site before APress contracted him... ;-)
Please accept my award for the stupidest gag of the week. It has been one of these weeks - so I've had to content with a lot of stupidy - but you win the award with a considerable margin. The moderators should, in my humble oppinion, remove your post. Have you considered doing away with yourself? It would be a kindness which you could offer the world. Have a really good day
How many beans make five, anyhow ?
Python caused me to change my layout for code, almost instantly eliminating a big problem with c-like code: the missing brace.
Most code is structured like this:In this small segment, notice that there are to sets of braces - and they don't line up at all. You have to mentally follow the code after "fubar" and see that after the condition "if (c())" in order to mentally track the state of the braces.
Compare this to
(slashdot's ECODE filter sux0rs)
If you could see it, you'd notice that the braces line up. The opening and closing braces for the condition "if (c()))" are indented one more than the braces for function Fubar() which are indented more than the line "Function fubar()" itself.
Thus, you merely have to follow the indents to match the opening/closing braces. As a result of this change, I spend less than 5 minutes per week matching up braces without the need for an IDE to match them up for me.
Python seems to be a good language (I like that you can compiles sections of a Python program in c to improve performance without rewriting the whole program) but it's concepts of layout certainly carry beyond Python itself!
I have no problem with your religion until you decide it's reason to deprive others of the truth.
Does the book cover custom network services? Writing forking/threaded/pooling servers? Correct error and signal handling, checking for duplicate instances, many platform specific issues, etc?
Seems not.
Sure, it does things. Next. How would it do them securely? Uhh yes. You can inherit ssl wrappers and such. Nicey. Take a closer look at them. They don't have strict enough certificate checking etc functions. Got to scrap Python for any _real_ valuable environments. Period.
I was wondering about that line. Are you telling me the cops have been busting me for littering? Winter's coming on, so I'm going to be wearing socks anyway. Clean up will be easy.
"Mark Pilgrim pretty much got a special exception from apress to allow his book to be downloaded, IIRC."
So: Mark Pilgrim, Phil Greenspun, Richard Stallman - any other authors to look for?
Last time I checked (2004-10-15 12:27 PST) it ranks 37 in amazon.com!!!
So I went out to verify the sales rank for other books. They result looks quite sane.
Java Network Programming, 2nd Edition (Java (O'Reilly)) by Elliotte Rusty Harold
Amazon.com Sales Rank: 81,978
Core PHP Programming, Third Edition by Leon Atkinson, Zeev Suraski
Amazon.com Sales Rank: 38,910
My Life by Bill Clinton
Amazon.com Sales Rank: 129
Is Amazon broken to rank this #37!
If you're a Perl programmer who doesn't know what Perl's weaknesses are yourself, and you have to ask me to spell them out for you, then you're an Incompetent Perl Programmer. You should have done that research yourself before deciding to use Perl. Shame on you! Put down the crack pipe and step away from the keyboard.
Incompetent Perl programmers who can't see or admit the flaws in their language are like the illegitimate president George W Bush who is out of touch with the harsh reality of Iraq and the economy, and therefore incapable of solving the problems. Incompetent Perl Programmers and Illegitimate US Presidents need to face the reality before they're qualified to solve the problems.
Aaron Weiss said: It's not a secret that Perl is structurally flexible, and the conventional wisdom is that Perl gives you "enough rope to hang yourself". Funny. But that's not the gripe -- go ahead, hang yourself if you want. That's freedom. The problem is that Perl also gives you enough rope to hang others."
Eric Naggum said: It's not that perl programmers are idiots, it's that the language rewards idiotic behavior in a way that no other language or tool has ever done.
Peter da Silva said: The syntax is awkward, overcomplex, has too many obscure special cases (there's to many obvious examples to list, I'll just mention one of the obscure ones: the way scalars and collections in for loops are treated), and the result is that you have to not just "know Perl" you have to be a Perl language lawyer just to avoid wandering into a dark alley and getting figuratively mugged by some cool feature.
Nicholas Clark said: That indirect object syntax is worthy of hate. (I think)
In the Switch documentation, Damian Conway said: BUGS: There are undoubtedly serious bugs lurking somewhere in code this funky :-) Bug reports and other feedback are most welcome.
LIMITATIONS:
Due to the heuristic nature of Switch.pm's source parsing, the presence of regexes specified with raw ?...? delimiters may cause mysterious errors. The workaround is to use m?...? instead. Due to the way source filters work in Perl, you can't use Switch inside an string eval.
Matt McLeod said: But the moment you try to anything properly, try to modularize and, you know, do perverted things like *reusing code*, it becomes a pain in the arse. One exciting feature I came across recently is that under certain circumstances you can create what seems like a module which exports a bunch of names, but if you don't start the name with an upper-case character it only exports the first. And it won't *tell* you this is what is going on (even with -w and use strict), it just whines that it can't find &main::foo() when it's supposed to be getting &thing::foo(). Don't even get me started on the flatten-all-arguments-into- a-list-of-scalars bullshit. Or the lack of any decent support in the basic language for datastructures other than lists. I'm sorry, walking through an array of arrays of hashrefs is not a substitute for a record/struct datatype, and having to fight it's alleged OO model to use a third-party "class" do what would be a simple job in anything else is completely not acceptable to me.
Lars Marius Garshol said: Casting of operands in comparisons: induced errors. Redefinition of some C keywords: walltrap. Overcomplexity 1: suffix condit
Take a look and feel free: http://www.PieMenu.com
It's sad how many Perl programmers have invested so much prescious time learning their way around Perl's fractally complex syntactic surface area and nip picking legalistic style guides and conventions, that they're unwilling to consider learning other languages. Monolinguistic Perl programmers are afraid to learn other languages because they're under the mistaken belief that programming languages are necessarily complex and hard to learn. They're afraid to admit that they've wasted so much time learning Perl's nuances, when they could have used a better language and invested that time in solving problems instead of memorizing trivial syntactic details.
If Perl was designed well in the first place, you would not need all those nit picking legalistic style guides and conventions to tell you which parts of the language never to use, which parts don't work together with each other, and how it breaks down under so many different situations.
The concept of "DWIM" programming languages is doomed to failure. The Lisp community figured that out many years ago.
-Don
Take a look and feel free: http://www.PieMenu.com
Conjoined Fetus Lady
So why do you choose to use a language whose OO facility you admit is quite the abortion? Python and Ruby and other languages have 100% of the power of Perl, with well design OO facilities, without the cojoined fetus attached to the side of the head.It just astounds me that people cling to such an abortion of a language, while rejecting Python for such a shallow reason as white space indentation. Most people who complain about that problem haven't actually tried programming in Python, and they come back later and say that it doesn't bother them at all once they get used to it. If your real complaint is just that you don't like being forced to indent your code, then you should go get a job at McDonalds instead of programming.
The reason COBOL and FORTRAN "should have been thrown out" has nothing to do with "white space parser tokens". The problem is that there are enormous amounts of legacy code written in COBOL and FORTRAN, which is extremely expensive and difficult to maintain or upgrade, because its behavior is impossible to untangle thanks to the language's lack of modularity and support for programming in the large. And that's exactly the same problem that Perl has, and the reason that Perl should be thrown out, but never will be.
People are finally beginning to wake up to the problems of Perl. Perl is like DDT and Asbestos: It's been used for far too long without considering its long term side-effects, and now it's everywhere polluting the environment. DDT was the ultimate "DWIM" pesticide, as Perl is the ultimate "DWIM" language. Just as the Asbestos Abatement Industry removes hazardous material from buildings, and the Cobol Abatement Industry removed Y2K bugs from code, the Perl Abatement Industry rewrites the code of failed dot-com companies whose intellectual property has been bought up by bigger dot-com companies. Not nice work, but it pays well because it's working with hazardous materials.
Python is no less expressive or powerful, and no more complicated or harder to learn, because of white space indentation. It was a well thought out trade-off, whose upside vastly outweighs its downside. White space indentation makes code easy to read, and it forces sloppy people to clean up their act, which is a good thing.
If you accept Perl's abortion of an OO system, then why do you reject Python's white space indentation? Learning another language would give you a better sense of perspective.
-Don
Take a look and feel free: http://www.PieMenu.com
Shakespeare, Tolstoy, Dostoyevsky, Plato, and lots of others are available copyright-free at the Gutenberg Project.
I fail to understand why anyone would want to use a language that uses whitespace or tabs to deliniate program structure. This seems a sure way to get in real trouble. Any corruption of the source could really screw up the source so bad that it couldnot be recovered!
Comment removed based on user account deletion
-Don
Take a look and feel free: http://www.PieMenu.com
If you didn't already know those points I raised about Perl and the fundamental problems of "DWIM" programming languages, then you're simply not a competent programmer. The information is out there, go look it up and learn it yourself.
My point is that there are a lot of incompetent Perl programmers out there who are oblivious to the fact that they should be using much better languages, and not polluting their minds and the environment.
I'm against using Perl for the same reasons I'm against using DDT, Asbestos and Lead. They may have seemed like convenient, expedient shortcuts at the time, but you absolutely must consider their debilitating long term effects.
-Don
Take a look and feel free: http://www.PieMenu.com