Expert Python Programming

Expert Python Programming by Tarek Ziade

Expert Python Programming

Binding:
Paperback
Number of Pages:
376
ISBN:
184719494X
Product Group:
book
Publisher:
PACKT PUBLISHING
Publication Date:
Sept. 22, 2008
BooksForGeeks.com ID:
2365

Reviews for Expert Python Programming

  1. What I thought I knew about Python

    Rated 4 out of 5 stars, February 12rd, 2009

    I disagree a little with other reviewers over the English and the examples. There's a few small issues of the editing, but nothing that interrupts the flow of the book.

    The examples are sometimes a little long-winded, but at the same time I hate paper-tiger examples that you would never see in real code, so I'm of the opinion that at the advanced level, you can extract the generalities from specific code.

    I've written a review elsewhere, so I'll keep it brief: this book offers an introduction into the advanced features that Python has and other languages don't. If you think you know Python, you may be surprised. And if you're trying to sell Python to people who know a half-dozen languages already, this book may be the key.
  2. Made concrete improvements to the way I work with Python every day

    Rated 4 out of 5 stars, January 12th, 2009

    [Publisher Packt were nice enough to send me a copy of this, so I'm completely biased, but fortunately I really liked it.]

    I've been using Python for a couple of years now, but only on a single project, so while there are parts of it that I know very well, there is doubtlessly a lack of cross-fertilisation in the things I am exposed to. So I was looking forward to this book.

    Surprisingly, for such a straightforward-sounding title, it is not at all what I expected.

    What I expected was analyses and illustrations of using Python's more powerful features: dynamic designs; creating classes on the fly; functional programming styles; closures and metaclasses.

    Sure enough, there is an early couple of chapters devoted to advanced language features. First up, iterators, and generator expressions, and then the .send, .throw and .close methods on a generator, which induce the yield statement to return values or raise exceptions. This is then used to handily illustrate coroutines as a method of co-operative multi-tasking without the calamity involved with getting all multi-threaded. It's exactly the sort of feature I'd pondered writing for myself for a personal project, oblivious that the language provides it out of the box.

    Other low-level topics covered include the indispensable itertools module, interesting uses of function decorators, best practices for subclassing built-in types, sensible use of descriptors and properties, understanding method resolution order and using super, the often-overlooked slots, and finally meta-programming and metaclasses.

    Interestingly, this list has only one item of overlap with my expectations. Tarek has done a good job of choosing important but sometimes overlooked topics, and while, inevitably, I was very familiar with some of the things he talked about, other sections were complete revelations for me.

    However, this is only chapters 2 and 3! The rest of the book expands in scope beyond Python the language, to look at the environments and tools that make up the Python ecosystem. In a way, this sounded less intriguing to me than the computer-science oriented exploration of language features that I had expected. But having finished the book, I now realise that it was exactly what I needed.

    The opening chapter goes through installing Python - a topic which I didn't think needed discussion. But Tarek goes on to cover using MinGW and MSYS to set up a credible command-line environment under Windows. I've always used Cygwin for this in the past, and trying out MSYS (coupled with the project Console) is a breath of fresh air.

    This cross-platform development environment is then rounded out a little by installing and using things like setuptools, and some thoughtful notes on integrating Python development into editors like Vim and Emacs, or an IDE like Eclipse.

    The rest of the book covers some of the major tools in the Python world.

    I've never previously been forced to get to grips with Distutils. Applying lessons from the book to a personal project got me completely up to speed with using Distutils to create packages, making source and binary distributions, using eggs, and distributing dependant packages that together make up an application. The only thing really missing from this is maybe generating stand-alone executables using py2exe (for Windows) or py2app (for Macs), although this idea is mentioned in passing.

    The following chapters give competent overviews of a wide variety of topics:

    8. Version control systems: centralised, illustrated by Subversion, or distributed like Mercurial. Continuous integration using Buildbot. Presumably you will either already know these inside-out or else will lap them up hungrily.

    9. Waterfall, spiral and iterative project life cycles. I'm not sure that waterfall is really used by anyone except in case studies of `what not to do', and I'm also not sure how you could be a developer without being aware of this, but maybe that's precisely the point: You can't be a developer if you don't do this. This chapter then covers setting up an instance of Trac and using it to manage a project's deliverables, defects, and milestones.

    10. Documenting a project using ReStructuredText and Sphinx, and including hints on good technical writing. This caused me to completely revamp the content of my small personal project's documentation, and as a result it is both much improved, and shorter to boot. Wins all round.

    11. Test-Driven Development. This chapter would be a superb overview of the topic for someone who didn't know about TDD. Although I use TDD extensively at work, I've never used nose, fearing that getting to grips with it might be too intrusive or disruptive. In fact, it is seamless to begin using it in a small way and slowly extend into its more advanced features as and when you need them.

    12. Optimisation : General principles (ie. don't) and profiling techniques. I had never used the cProfile module described here, having just whipped up homespun profilers on-the-spot whenever I needed them, and it's a valuable addition to my arsenal.

    13. Optimisation : Solutions. Big O notation. Correct use of different collection types. Multi-threading, multi-processing, caching. Not much that is tremendously new to me here, but it is obviously a huge topic to cover in a a single chapter, and it covers the bases competently.

    14. Design Patterns, and how they apply (or don't) to Python. It has been said that design patterns, as fundamental and necessary as they are to a software engineers mindset, are a symptom a language's lack of expressivity. You shouldn't have to write huge gobs of code to express simple conceptual relationships. Although Tarek never explicitly says this, to some extent it is born out by this chapter. Trivial (and much-maligned) ideas like the Singleton, after a page or two of alternate implementations, boil down to simply `use a module', i.e. zero lines of code. Slightly more complex patterns such as Visitor, are only a few lines. It is still useful to discuss and name patterns, but on the whole reference implementations are so trivial as to be unnecessary, except perhaps as the most concise and precise method of illustration.

    The book overall, then, is a grab-bag of different topics. Each chapter could clearly be expanded into one or more whole books. As a result, no part can be covered in very great depth, but Tarek does an admirable job of getting the reader up to speed enough in each area that they can be self-sufficient and direct their own learning from that point.

    It's worth noting the the book is based on Python 2.x, buy because of the high-level approach, this scarcely matters. Get a different book if you need to know about the language syntax and features. Get this to find out how to create and distribute Python projects.

    As as result of the broad scope of the book it serves as a brilliant annotated laundry list of `things the Python developer ought to know'. While there will doubtlessly be some sections that you are already deeply familiar with, if you have any interest in discovering your own deficiencies as a Python programmer, I can highly recommend it.
  3. A decent enough attempt at covering more advanced Python techniques

    Rated 3 out of 5 stars, November 12nd, 2008

    I read the other review on this site which wasn't very positive, but bought the book anyway - after all AFAIK this is currently the only one-stop-shop book covering Python's more advanced techniques.
    I must say that whilst there are occasional places where the author's English is less than brilliant it does not detract from the vast majority of the book and IMHO 1/5 is not a fair review. I read whole book in 2 days and perhaps had to reread 3 or 4 sentences, and even then I got what he was trying to say, even if it wasn't the most elegant English ever. I agree however that the publisher really, really should have spotted these - but don't write the book off because of this!
    The book covered almost everything I expected and a few things I didn't. The great thing about it is that most of my advanced Python knowledge has been cobbled together from blogs, PEPs, and Python.org; it is great to have most of these topics in one book from one author who knows his stuff.
    My main criticisms of the book are not the English. The thing that bugged me was that quite a few of the worked examples are over elaborate. With advanced techniques I'd expect the vehicle for demonstrating the technique to be as numpty as possible. However, often these examples are over complex, eg one example uses SQLAnalyser to demonstrate a technique - this is totally superfluous to the topic and you end up missing the wood because of the trees. I'm not a DB guy so I was annoyed I had to plod through DB code to peice together a technique I was interested in. Other authors (eg Scott Myers C++ examples) really strip down examples so you focus entirely on what is trying to be conveyed and not window-dressing-code in an attempt to make the example useful. It should be up to the reader to make the examples useful - espically at an advanced level - we don't need hand holding!

    Technically the only glaring omission from the book I can think of is a section on using callable objects to implement decorators. I find this method of implementing decorators more pythonic, intutitive and less complex than the function-wrapped-in-a-function (wrapped-in-a-function and so on) method explained herein. This could be argued as personal coding taste/style, but both methods should have been included for completness.

    My only other bugbear is I'd have liked to see more pages on pure python code techniques and less on building/maintaining/developing python - although other people may find this more interesting than I did, it was still an interesting read.

    Summary: If you already know python but are yet to play with some of the more advanced techniques, or you want to brush up on what you've cobbled together from umpteen sites you found on Google - this book is the only one that will meet your requirements, and it does a decent, if not brilliant, attempt at conveying these ideas.

  4. Poor english

    Rated 1 out of 5 stars, October 12rd, 2008

    I was looking for a book that would give me insight to advanced Python techniques and help me improve my Python knowledge and programming skills.

    So far, I'm up to page 43 (of 342) and I'm struggling to understand what the author is trying to say, not because it is too technical, but because of the English.

    It seems that English is not the native tongue of the author, so all credit to him for working in a foreign language; however, a subeditor at the publisher's should have made some changes.

    A couple of examples from pages 40 and 41 of this book:

    "Threading is an alternative to coroutines in Python. It can be used to run an interaction between pieces of code. But they need to take care of resource locking ..."

    "'throw' allows the client code to send any kind of exception to be raised."

    In most cases I can work out what the author is trying to say, but I am spending more time decoding the meaning of the text than I am understanding the Python.

    Very disappointing.

Our Network

BooksForGeeks.com is a participant in the Amazon Europe S.à r.l. Associates Programme, an affiliate advertising programme designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.co.uk