Follow Slashdot blog updates by subscribing to our blog RSS feed


Forgot your password?

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 Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

Beginning Python: From Novice to Professional

Comments Filter:
  • by TheDoctorWho ( 858166 ) on Wednesday January 11, 2006 @03:30PM (#14447932)
    'mazing ain't it?
  • by Nichotin ( 794369 ) on Wednesday January 11, 2006 @03:30PM (#14447934)
    I hope this is not modded off topic. Here goes:

    I am probably not the smartest person in the world, and I have no programming experience what so ever. What I am looking for, is some easy language to either script or program. Would python provide a good starting environment? Have any of you been at my level, then learned python?
    I have tried to do as much research as possible myself, but it seems that everyone I ask just woke up one morning, and found themselves to be able to program three or more languages (in other words, they do not remember how they started out). I have also tried to learn several languages by reading some O'Reilly books and similar, but I have been put off by the seemingly academic english that is used (my native language is norwegian, by the way).

    If anyone have any recommendation, as tho where to start, I would be more than happy.
  • by Wisgary ( 799898 ) on Wednesday January 11, 2006 @03:33PM (#14447965)
    I was at borders yesterday and I saw maybe 500 books from O'Reilly, 500 more from thompson and 1,000 more from random publishers, please for the love of god someone help me out and name me some *good* python books for an intermediate programmer. Most of my experience is in C++ and I would like to learn a high level language like Python, so please name me some books and help me in this impossible quest at borders.
  • by T.i.m ( 149429 ) on Wednesday January 11, 2006 @03:50PM (#14448137)
    Two years or so ago I made a CS master thesis where I tried to find / create the perfect language and IDE for learning to program. I did a pretty thoroug study of what is available and what is desired in such an environment. And i came to the conclusion that Python is very close to a perfect place to start learning programming.

    I starred to make som tweas in the environment and the language but "Unfortunatley" I got a job right after I finished so I didn't have time to finish the projec. In case someone is interested, more information and a manhandle beta can be found at: []

  • by lawpoop ( 604919 ) on Wednesday January 11, 2006 @04:20PM (#14448427) Homepage Journal
    In Perl, it is easy to make legible code, and it is easy to make illegible code.

    In Python, it is easy to make legible code, but it is difficult to make illegible code.

    I would argue that this fact makes it harder to write legible code in perl than in python.
  • by Baricom ( 763970 ) on Wednesday January 11, 2006 @04:39PM (#14448584)
    I know many others are going to cringe at this, but I would suggest starting with PHP. It's not traditionally taught as a first language, but I think it has some positive qualities that might make it useful.

    First, PHP shares much of its syntax with other popular languages today. It looks a lot like C*, Perl, Java, and JavaScript. The control structures, many of the operators, and other parts of the language are all remarkably similar. In my opinion, this will reduce your learning curve as you tradition to other languages.

    Second, PHP is ubiquitous immediately applicable. You can find it installed on almost any web server, and in a variety of other places. It is designed around being used to create web pages, but it's also rich enough to use it as a general-purpose scripting language without much trouble. Additionally, the core functions take care of many details you may not want to deal with right away, but it gets out of your way if you want to dig deeper into how everything works.

    For what it's worth, my learning path as a programmer was GW-BASIC to QBasic to Visual Basic to Perl. I started in elementary school by typing in programs from old children's books. I picked up OOP concepts from Visual Basic. Today, I do most of my programming in PHP, but I have a passing familiarity with Perl and to a lesser extent, Python.

    I know a lot of languages, but none very well :)

    The ability to do basic (no pun intended) programming is incredibly liberating. Good luck!
  • Re:Devouring? (Score:5, Interesting)

    by Reality Master 101 ( 179095 ) <RealityMaster101 ... minus city> on Wednesday January 11, 2006 @04:40PM (#14448598) Homepage Journal
    Just to make another useless-but-interesting experiment, I tried the following: Google for:
    "written in python": 665,000 hits
    "written in perl": 1,140,000 hits
    "written in c": 1,500,000 hits
    "written in c++": 772,000 hits
    "written in c#": 342,000 hits
    "written in java": 1,750,000 hits
    "written in haskell": 33,600 hits
    "written in lisp": 61,400 hits
    "written in pascal": 51,800 hits
    "written in objective c": 26,800 hits
    "written in ruby": 120,000 hits

    I'm not sure what this measures, but it's interesting. :) Python actually did a lot better than I expected.

  • Python Riddles (Score:3, Interesting)

    by AlXtreme ( 223728 ) on Wednesday January 11, 2006 @04:58PM (#14448768) Homepage Journal
    Recently came across pythonchallenge [], it's a notpron/riddle site for learning Python, with each riddle requiring more and more code. Great idea, imho.

    As if python itself wasn't fun enough :)

  • Re:python regexes (Score:1, Interesting)

    by Anonymous Coward on Wednesday January 11, 2006 @05:03PM (#14448828)
    I use both Perl and Python frequently, and have taught beginning programming courses in both.

    Python regexes do anything Perl regexes can do, but they aren't as fully integrated into the language: you have to type more characters to accomplish the same thing. Regexes are a hugely common task, so this difference is significant for many real-world uses, particularly short one-time-use scripts used by system administrators.

    As with many areas of comparison between Python and Perl, the extra effort will sometimes make for better programming in the long run (eg, encourage you to precompile your regexes for better performance). When you only want a quick-and-dirty, use-once-and-throw-away script, Perl will be your choice. But if you plan to re-use your code (or if you don't plan on it but later wish you had), Python is worth the slight differences, even the strange ones like the unique approach to list indexing.

    The most important example of how Python is better for code re-use, in my mind, is exception handling. Python has a built-in, powerful, hierarchical (you can just catch a parent class and be sure you're handling all the children), nestable, extensible (define your own exceptions) system of exception handling. Perl has eval blocks. You COULD use eval blocks to write nested exception handling, if you religously catch every exception and re-throw what you don't handle. But that strategy is laborious and error-prone and I've never seen anyone seriously attempt it.

    In short, Perl makes you do extra work to support stuff (like exceptions and, to a lesser extent, inheritance) that should be built in to a modern language. Python can feel awkward (compared to Perl, but try doing this stuff in Java) trying to do some common stuff that ought to be easy (like regexes). It all depends which features you value.

    To return to the topic at hand, Python's "one right way" mindset can be more of an obstacle than it should be, because the documentation isn't geared toward newcomers. Say you're starting out in Python (or haven't used Python in ages) and you need to concatenate a string and an integer. The answer is simple and concise, but see how long it takes you to find it in Python's online documentation. I hope that new books will help.
  • by Jason Earl ( 1894 ) on Wednesday January 11, 2006 @05:14PM (#14448922) Homepage Journal

    The funny thing about cross-platform applications is that, until you have done a few, it is easy to make mistakes. This is especially true if the software in question is not entirely self-contained. Heck, Windows even has different file handling abilities than most other systems. In the real world these issues are thorny enough that most people don't really bother. After all, most applications only end up running on one architecture. In fact, most applications only end up running on a handful of machines. Python is easy enough to use that you quickly find yourself writing scripts that are not only custom to your machine, but customized to the way that you like to work. For example, I have a set of scripts that I wrote for altering the HTML versions of's ebooks so that they make slightly nicer plucker ebooks. Next thing I knew I had a script that logs into my account using my username and password, downloads all of the new books I have purchased, mangles them, and formats them as plucker ebooks. It then checks to see if there are any new free ebooks on baen's site and downloads and formats them as well. Lastly, it updates of list of "books to read" so that I can know which books are new and which books I have already read.

    Clearly, I am not the least bit interested in making sure that particular piece of software is portable. Why should I? I know perfectly well that for the forseeable future my home desktop will be a Linux box. I chose Python (over Java which I use professionally) because I knew that Python would get the job done in less time. HTTP transfers, zip files, HTML mangling, etc. are all things that Python does extremely well with a minimum of fuss.

    Basically, I use Python because it is fun. The fact that I can easily write portable software is part of what makes Python fun (it makes what can be a difficult job painless and easy), but it is only a part of what makes Python fun enough that I use it to mangle ebooks instead of mangling them by hand.

  • by GalacticCmdr ( 944723 ) on Wednesday January 11, 2006 @05:16PM (#14448940)
    * You don't have to declare variables
    * Code blocks are simply based on how you indent, making it always very legible
    These are the two very reasons I dislike python. It is far to easy to have a typo cause problems in the use of a variable. Since you do not have to declare variables if you want striker, but instead fatkey in an increment to strikr then it becomes a problem that can be difficult to find.

    Second, any language that requires indenting to signify code blocks is in my mind a great step backwards to the days of Fortran. This makes code blocking too vulnerable to pretty printers and version control methods that may "adjust" indentation.
  • Re:Devouring? (Score:4, Interesting)

    by killermookie ( 708026 ) on Wednesday January 11, 2006 @05:30PM (#14449060) Homepage
    "written in php": 2,190,000 hits
  • Re:Devouring? (Score:3, Interesting)

    by belmolis ( 702863 ) <billposer.alum@mit@edu> on Wednesday January 11, 2006 @05:34PM (#14449103) Homepage

    Here are the current Freshmeat [] statistics. The numbers are the number of projects in the specified programming language. I've omitted those with fewer than 10 projects. They probably give a fairly good idea of the popularity of programming languages if you take into account the bias toward the Free Software world. In the MS Windows world Visual Basic, for example, would no doubt rank much higher. Also note that these are cumulative over the past 6 years or so.

    C 7863
    Java 4567
    C++ 4077
    Perl 3569
    PHP 3529
    Python 2234
    Unix Shell 852
    JavaScript 634
    SQL 475
    Tcl 455
    Objective C 321
    Ruby 289
    Assembly 238
    C# 217
    Scheme 127
    PL/SQL 88
    Delphi 83
    Lisp 83
    Fortran 69
    OCaml 63
    Ada 62
    Common Lisp 60
    Emacs-Lisp 60
    Haskell 58
    Pascal 56
    Awk 46
    Zope 46
    ASP 40
    Visual Basic 37
    Eiffel 33
    ML 32
    Basic 31
    Smalltalk 31
    YACC 30
    Cold Fusion 27
    Forth 24
    Lua 23
    Erlang 21
    Object Pascal 20
    Prolog 20
    Pike 14
    Rexx 13
    Modula 10

    For the scripting languages, Perl and PHP lead, followed by Python, then Javascript, then Tcl. Ruby still isn't that popular on Freshmeat, and Lua, REXX and Pike hardly register.

  • Re:Devouring? (Score:3, Interesting)

    by Naum ( 166466 ) on Wednesday January 11, 2006 @06:01PM (#14449346) Homepage Journal
    "written in COBOL": 43,100
    "written in REXX": 809
    "written in CLIST": 168
    "written in scheme": 34,900
    "written in RPG": 700
    "written in FORTH": 10,900
    "written in objective-c": 26,700
    "written in WFL": 5
    "written in tcl": 106,000
    "written in bash": 24,000
    "written in korn": 480
    "written in smalltalk": 20,400

    And finally...
    "written in curses": 40
  • Language Discipline (Score:3, Interesting)

    by Tony ( 765 ) on Wednesday January 11, 2006 @06:30PM (#14449585) Journal
    . . . but if you are serious about maintainability then, to my mind, language enforced coding standards and a certain amount of "one right way to do it" has real value.

    Perhaps for you.

    "Maintainability" is undefined for this problem set. I can't maintain Python code because I fucking despise the language, for the same reason I don't like anal uptight bastards in three-piece suits -- it's inflexible. There's only one way of doing things, and often it is not be best way in specific situations.

    For me, it always comes back to blocking. Whitespace-as-blocking is a straightjacket, chosen for aesthetics, and not for any practical reason. This design philosophy permeates Python, making it one of the ugliest languages I know.

    It's like music. Any number of corporate-whore bands create smooth, aesthetic music that is bland and boring. I like my music hard, with sharp edges and dangerous points. For me, Python has always been the N*Sync of the programming world (VB is like New Kids On The Block, fwiw). Perl is more like the Pixies. LISP is like the Beatles. C is like the Stones. FORTH is like Gus' first album. Assembly is like the Black Keys. Java is like Abba.

    Huh. This is kinda fun.

    Now you can tell me about how programming is engineering, and not art. Go on, I know you want to.
  • Re:O, yeah? (Score:3, Interesting)

    by Just Some Guy ( 3352 ) <> on Wednesday January 11, 2006 @06:58PM (#14449828) Homepage Journal
    The reason that drove me nuts, though, is that you had to handle objects returned from a function differently than objects you created in the same scope:
    my ($a, $b, $c) = foo();
    print $a->{'one'};

    my %d = ('one' => 'ein', 'two' => 'zwei');
    print $d{'two'}

    Of course, you could always deference $a into another variable and access it that way instead, but that's the sort of "throwing extra code at it" that I meant.

    I'm not saying Perl is bad. A lot of people use it to do lots of things. For me, though, the warts eventually overwhelmed the pearls and I went looking elsewhere.

Happiness is twin floppies.