Beginning Python: From Novice to Professional 436
nazarijo writes "Python seems to be devouring everything these days,
with more and more people using it for serious projects. It's quickly
supplanting Perl in some circles, and with good reason. It's a powerful,
richly featured language with boatloads of extensions. And, unlike Perl,
it's very easy to do complicated things in simple, legible code. Python
books are still only a small part of the shelf at your local bookstore
when you compare it to the popularity of Perl, but which ones are the gems
and which ones are fluff? Having looked at a lot of Python books in the past
couple of years, I think that Beginning Python: From Novice to Professional
is the one that I'll most recommend to people." Read on for the rest of Jose's review.
Beginning Python: From Novice to Professional | |
author | Magnus Lie Hetland |
pages | 604 |
publisher | Apress |
rating | 8/10 |
reviewer | Jose Nazario |
ISBN | 159059519X |
summary | Tour the Python language, from basics to advanced modules |
Beginning Python is loosely grouped into three main sections. The first deals with Python fundamentals, all the goodies that are inherent to the language and the modules that it ships with. It's surprising to see how rich the language is out of the box, especially when compared to some other scripting languages. The second section would be the chapters covering popular extensions for a variety of services. These include network and web programming, SQL objects, and even GUI programming. And finally the third section is a set of 10 projects in Python, which bring everything together in a concise fashion.
I like this book a lot because it is very clear in its delivery, both the prose and the code examples used, and is consistently Pythonic. The Python language lends itself to a powerful programming style and, unlike Perl, many Python developers I know don't bother with a dozen ways to perform a simple action, they get it done and move on. What you wind up with is clear code that's easily understood by someone new to the language.
Unlike what the title would suggest, Beginning Python isn't only for the first few weeks with the language. The book is large and in depth, and the coverage of material is fantastic in many ways. You get a quick tour of the basics and then you move on to an overview of the language and then its common features. The inclusion of the 10 projects is another benefit to the intermediate user. She can refer back to this book for additional information and pointers from time to time, it wont sit still on her shelf.
That said, there are a few things in the book that I tend to disagree with. For example, the author dissuades you from using destructors in your code, but in my experience they're far more reliable, and a better place to do some cleanup, than he states. A few chapters are also a bit skimpy when they didn't need to be. For example, Chapter 18, which covers packagers like the distutils component from Python, needed to be fleshed out a lot more. This is a powerful feature in Python and sound docs on it should just be there. There's no reason to hold back on something so vital. The section on profiling in Chapter 16 is also a bit thin around the middle when it needn't be. While this seems like a minor point, having a reference to speeding up code (and measuring the improvements) is always nice. And finally, Chapter 17, which covers extending Python, is simply too short for its own good. A more in depth example would have been appreciated.
I have begun recommending this book to people I know that are smart and program in other languages, but aren't very familiar with Python. Many beginners books only take a person so far before they become a useless item on the shelf. This means that he $30 or more that was spent is now gone, so I've grown to be observant of how long I expect a book to be useful. I anticipate the useful shelf life of Beginning Python will be longer than average for most general purpose programming books for a single language. What's more is that it's not a dry reference book. Couple this to a Python cookbook for recipes and you have a two volume "mastering Python" series.
If you've been curious to learn Python and haven't yet found the book that speaks to you clearly, this may be the one. I'm pleased with the quality of the writing, the examples, and the quick pace of the book. While it's nearly 30 chapters in length, most of them are short and focused, making them easily digestible and highly useful. Overall probably the best Python books I've had the good fortune of reading."
You can purchase Beginning Python: From Novice to Professional from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
free python tutorial from book author (Score:5, Informative)
Not only is this a good book, it is also one of only few that cover Python 2.4. The author Magnus Lie Hetland has a free python tutorial ("minimal crash course) (Instant python [hetland.org]) on his homepage. He was also involved (as author, editor etc.) in several other book projects:
So we can assume he has a clue what he is writing about.
His homepage [hetland.org] uses PHP, btw.
Chriss
--
memomo.net - brush up your German, French, Spanish or Italian - online and free [memomo.net]
Damn perl bashing (Score:0, Informative)
By the way, you have fun with that whitespace requirement.
Re:being python (Score:3, Informative)
Devouring? (Score:5, Informative)
From Dice.com
Python : 545 matches
Perl: 3809
C#: 3850
Ummm over 1/8 of the demand of Perl or C#
Java: 11856
Java+BEA: 621
So Python is smaller than one specific application servers development requirements.
Python is better than Perl, but in terms of devouring? Its like saying that American Football is devouring other sports around the world.
On a related note... (Score:3, Informative)
It's licensed under the Creative Commons "Attribution-Share-alike" License, so feel free to pass it around if you want to.
Re:free python tutorial from book author (Score:4, Informative)
http://www.oreilly.com/catalog/pythoncook2/ [oreilly.com]
Re:Totally fresh in programming (Score:5, Informative)
Also, for a very different, novel and fun approach you should check out Why's Poignant Guide to Ruby [poignantguide.net]. Did I mention it was fun? It's also a great intro for someone who has never programmed before.
Re:Totally fresh in programming (Score:5, Informative)
Absolutely! I think it's one of (if not the) best languages for new programmers. My main reasons are:
Opinions will vary, of course, but I think that Python is an excellent choice to start with.
Have any of you been at my level, then learned python?
Nope. When I was at your level, I had to learn a lot of really awful languages because the average person didn't have access to the nice ones. I would have loved having something so easy to learn and powerfully expressive at the same time.
Re:Totally fresh in programming (Score:2, Informative)
It helps because I can write one program for Linux, it works on my Windows PC with minor mods, and even works on my wife's Palm with similiar minor mods.
Python is a platform independant object-oriented programming language. It's great to learn, and it's great to start your learning with.
Re:Totally fresh in programming (Score:5, Informative)
* You don't have to declare variables
* Code blocks are simply based on how you indent, making it always very legible
* You can easily see what functions are available in a package using dir(), and you can get brief help information on a function by print function.__doc__, from within any python shell.
* Very simple to do things that might take a long time to in lower-level languages - reading contents of files, splitting strings, performing regular expression matches, etc.
* Performance is tolerable for most applications - just don't try to write Quake or physics calculation software in it.
Re:Civilization IV is Python and XML (Score:3, Informative)
Re:Damn perl bashing (Score:5, Informative)
Re:Totally fresh in programming (Score:4, Informative)
Dive into Python (Score:4, Informative)
Python? Why not Ruby (on Rails)? Because ... (Score:5, Informative)
Since this is inevitable to pop up, a very simplyfied version (slightly offtopic):
Why not ditch Python and use Ruby (on Rails)?
Why better stick with Python?
Chriss
--
memomo.net - brush up your German, French, Spanish or Italian - online and free [memomo.net]
Re:Totally fresh in programming (Score:3, Informative)
My hatred of Java and VB aside, however, I would add this: Once you get a good grasp of how to program in Python, it would be time to cut your teeth on a lower-level language. C or C++ would work here. It's going to be a little rough, as you get used to the different requirements, but you'll learn a lot more about Comp Sci.
Also, and this could possibly go before you learned C or C++, you may wish to take a look at design patterns once you get the basics down. Addison Wesley has an excellent book on patterns here [amazon.com] (No, there is no referer BS in the link) which I encourage you to look at.
Re:Civilization IV is Python and XML (Score:5, Informative)
The AI can be reprogrammed in C++ using their API. See Question 6 [slashdot.org]. I'm not positive that it's been released yet though.
Re:Before too many people post please read this! (Score:3, Informative)
Re:Totally fresh in programming (Score:5, Informative)
For the most part Python software written on one platform will work just fine on any platform with Python installed. Python is completely portable in that manner, and official Python interpreters are available for a ridiculously wide array of platforms. However, if you don't take that portability into account when you start writing your software it is pretty easy to write bits that won't work when you move them to a platform with significant differences. For example, Python has APIs that deal intelligently with the various path separators, line endings, etc. that folks that write software for various platforms deal with every day. However, it's fairly easy to ignore these tools and do things like hardcode 'c:\MyDirectory\' into your application.
It is also possible to write Python software that uses third party Python extensions written in C or C++ that haven't been ported everywhere. Of course, this is possible in every "platform independent" language that I have heard of. It's certainly possible to do this with Java (witness IBM's SWT).
Learning Python (Score:3, Informative)
As a programmer experienced with OO programming and some other types of "scripting" languages, all I needed to read was Learning Python [oreilly.com] from O'Reilly. Great book, great language.
On a shameless side note, if you're a Scrabble fan, come check out my online, multiplayer Scrabble program written in Python. PyScrabble [sf.net]
A few good and free Python books (Score:4, Informative)
I suggest:
Good reading.
Re:python regexes (Score:3, Informative)
So, the calling convention is slightly different - one is procedural, and one is OO - but Python uses Perl's regexp engine so the patterns themselves should be identical.
I started with Perl (Score:2, Informative)
If a programming language is sufficiently powerful, you won't become proficient in it overnight. For myself, I went through three stages: tutorial, hobby, profession.
It started with me back in 1999 when I wanted to learn HTML, and so I set out to learn it. But in the mean time, a friend of mine in the business told me that with Perl you could pretty much do anything you want in making web applications. At the time, I didn't know the difference between server-side and client-side scripting, and I figured, why not give it a try?
So I searched on the internet and found Robert's Perl Tutorial. The introduction says, "It assumes that the reader knows nothing of programming whatsoever. .
Going through the tutorial took me two or three weeks. After finishing it, I decided to try to make my nascient website cooler than it was by adding some server-side scripting. Now that I wasn't just in the tutorial anymore, I had to learn something about CGI. That's when I found the site "CGI Programming 101", http://www.cgi101.com/class/ [cgi101.com] (I'm pleased it is still around, too.) From this I learned the rudiments of CGI programming with Perl.
From this, I wrote a program called Article Master, which, had I stuck with developing it, could have been *the* killer-app blogging software instead of MovableType. (I'm sure there are probably 50,000 other geeks out there who also started out with something like this, discontinued development on it, and are still kicking themselves in the butt for missing out on coming out with the killer app.) In any case, after building the software and getting it to work kind of OK, I developed a deployment package for it and submitted it to an online Perl script archive. After submitting it, the archive gave me a free email address and access to the exclusive programming forums. The site sent me an email telling me I got these exclusive benefits because I was a programmer.
I had never thought of myself as a programmer, but here was a site brimming with programmers telling me I was one of them. It was such a positive boost for me that it encouraged me further to develop my skills.
Soon enough, I bought the Perl CD Bookshelf from O'Reily. Now, I had all the information and reference material I needed to write almost anything I wanted. I did some other personal online projects, and then, somehow I got the idea to try out getting a job using Perl. (This was at the beginning of 2000, just before the dot-com bust, so the entrance bar was set pretty low.) I called up a head-hunting agency and asked them if they needed someone who knew Perl. The agent on the other side said, "Get down here ASAP!" I went, I took their computerized test, and the results made him do backflips. (Hey, I knew what JAPH meant, and that was a question on the test!) He said he would have no problem getting me into a job, which he did. (And the money was more than I had ever dreamed of making.)
When I started, I got an assignment (all CGI development) from one of the other lead programmers, and he asked me how long the job might take me. I hesitated, and just before I was about to say "a few days", he asked if I could do this in a few hours. I said, "Yeah, OK." I asked him if there was an HTML tool they used, and I just got this blank stare. I learned quickly that real Perl programmers don't use HTML editors--like our Perl code, we type everything else by hand. I somehow rose to the occaision and got the job done in time. From t
Re:Perl vs. Python (Score:3, Informative)
Re:python isn't just for web apps (Score:3, Informative)
Also, python does not have real threading support. It has the GIL which will prevent your threaded python app from using more than one processor, but it's still better than ruby's thread support. I don't think this is much of an issue for two reasons.
First, a lot of threaded apps are threaded because they are waiting on io of some sort usually network io. Ruby and python both work perfectly well for this type of threading need.
Second, I've only ever done one project that needed to be multithreaded so it's a non factor for me and I think most people are in the same boat.
yeah! OO stinks in perl (Score:2, Informative)
Perl == horrible bolted-on afterthought OO
Python == *much* better (real objects, finally!)
Ruby == pure heaven, everything is an object and iterable by default.
I was bored one day at home and recreated a class in ruby that I wrote at work in perl. Took me all day to do something in perl that it took about 1/2 an hour to do in ruby, and I added a couple of features as well. I also spent way more time looking up how to do stuff in perl that in ruby, event though I've programmed off and on in perl for years (a decade, in fact)....
Re:the obligatory Python vs Perl post (Score:2, Informative)
larry
Re:Totally fresh in programming (Score:3, Informative)
Ummm, Dude, yes [wikipedia.org] it [diveintopython.org] does [artima.com].
Guido seemed to be discussing dynamic versus static typing, not weak vs. strong.
Re:being python (Score:2, Informative)
Re:being python (Score:2, Informative)