Beginning Python: From Novice to Professional
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.
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.
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) 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 uses PHP, btw.
Chriss
--
memomo.net - brush up your German, French, Spanish or Italian - online and free
memomo: free web based language trainer DE-EN-ES-FR-IT
Perl is as legible as the author makes it.
By the way, you have fun with that whitespace requirement.
Not by far much, and Monthy Python based jokes are higly valued in Python the community and appreciated in python code/comments.
"The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
Python seems to be devouring everything these days... even replacing Perl
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.
An Eye for an Eye will make the whole world blind - Gandhi
It's licensed under the Creative Commons "Attribution-Share-alike" License, so feel free to pass it around if you want to.
Dewey, what part of this looks like authorities should be involved?
I would check out How To Program by Chris Pine. It's very much for people who have no programming experience.
Also, for a very different, novel and fun approach you should check out Why's Poignant Guide to Ruby . Did I mention it was fun? It's also a great intro for someone who has never programmed before.
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.
Dewey, what part of this looks like authorities should be involved?
Python was the very first language I used to learn to program. I had multiple people telling me to start with python, so I perused over to their site, picked up a few online tutorials to go through, and started building a library of python books.
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.
Evil Walrus >83=
Actually, yes, I would definitely recommend it. I started programming before Python (actually started in Basic because it was the only thing I had in 7th grade, then ran as quickly as I could away from it to a real language). However, python is a very easy language to learn and you don't need to deal with any advanced concepts to "make things work".
* 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.
The *special* hell.
No it isn't. The AI scripts are. THe engine is C++.
I still have more fans than freaks. WTF is wrong with you people?
My first language was C, learned in a first year university introductory programming course, but when friends have asked me about learning programming I have recommended they start with python and the book How to Think Like a Computer Scientist: Learning with Python http://www.ibiblio.org/obp/thinkCSpy/. Its available free online. This is a good introductory book with no expectation of prior experience that teaches the ideas behind programming, not just the syntax of the language.
No discussion of Python literature can be complete without mentioning Mark Pilgrim's Dive into Python, which is an excellent way to get to know the Python language. It's free for download in a variety of formats. Two caveats however, being that 1) it hasn't been updated in about a year and a half and 2) it assumes that you already have a pretty good grasp of programming in some other language. But if you've you got some coding experience and want to take a serious look at what Python has to offer, this is a great book full of nice examples (with the code available for download as well).
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: free web based language trainer DE-EN-ES-FR-IT
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 (No, there is no referer BS in the link) which I encourage you to look at.
No it isn't. The engine and the AI are written in C++. All of the game scripts (map generation for example) and interface is in python, all the game data is in XML, and it's highly modable.
The AI can be reprogrammed in C++ using their API. See Question 6. I'm not positive that it's been released yet though.
I've had good experiences with O'Reilly in general, and with "Learning *", "Programming *", and "* Cookbook", where * has been Python, Perl, PHP. However, have a look at http://python.oreilly.com/ and download the free chapters and source code before you buy. For an intermediate level programmer you can probably do without the "Learning Python" book. Good Luck.
Then again, I could be wrong.
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).
I am a Java programmer by profession but I wanted to give Python a shot because it seemed like fun.
As a programmer experienced with OO programming and some other types of "scripting" languages, all I needed to read was Learning Python 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
I suggest:
Good reading.
There's a hidden treasure in Python 3.x: __prepare__()
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.
Dewey, what part of this looks like authorities should be involved?
Since the start of the review is basically a flame against Perl, I can't resist making a plug for it--especially since it was the first serious programming language that I learned.
." On reading it, I knew this was for me. So, eventually I found out I had to download Perl, which I did, and then I started going through the tutorial. URL: http://www.sthomas.net/oldpages/roberts-perl-tutor ial.htm
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/ (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
yes and no. I use python and ruby at work and I prefer ruby as a language. Python does have better support and more mature libraries and it's a very nice language. We have a mix of linux and windows and python has much better windows support which is why we still use it as much as we do. The docs issue is weird. Ruby doesn't have as many docs, but I feel the docs they do have are often better (this is probably just personal preference). The python docs have left me wanting many many times. They are there for sure, but they can be really lacking.
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.
Objects!
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)....
If only "common" sense was actually that common...
larry
Ummm, Dude, yes it does.
Guido seemed to be discussing dynamic versus static typing, not weak vs. strong.
Dewey, what part of this looks like authorities should be involved?
One of the programs associated with Python is called Idle (used for typing code and then running without any compiling, good for quick tests), this name comes from Eric Idle, who was on the cast of Monty Python.
What day is it? Could you please tell me?
The language was actually named that because of Monty Python so that's not far off: http://python.org/doc/faq/general.html#why-is-it-c alled-python