Expert Python Programming: Best practices for designing, coding, and distributing your Python software
|
| List Price: | $44.99 |
| Price: | $35.39 & eligible for FREE Super Saver Shipping on orders over $25. Details |
Availability: Usually ships in 24 hours
Ships from and sold by Amazon.com
27 new or used available from $24.37
Average customer review:Product Description
In Detail
Python is a dynamic programming language, used in a wide range of domains by programmers who find it simple, yet powerful. From the earliest version 15 years ago to the current one, it has constantly evolved with productivity and code readability in mind.
Even if you find writing Python code easy, writing code that is efficient and easy to maintain and reuse is not so straightforward. This book will show you how to do just that: it will show you how Python development should be done. Python expert Tarek Ziadé takes you on a practical tour of Python application development, beginning with setting up the best development environment, and along the way looking at agile methodologies in Python, and applying proven object-oriented principles to your design.
What you will learn from this book?
- Set up a productive development environment
- Customize the Python prompt and deploy setuptools
- Write efficient syntax: iterators, generators, and decorators
- Build arguments by design and follow the best practices for working on API
- Build, release, and distribute your applications
- Write an application based on several eggs
- Distribute and deploy your application with zc.buildout
- Build and release your packages and set up a development cycle
- Manage your code with distributed version control and continuous integration
- Use an iterative and incremental approach to write software
- Practice Test-Driven Development
- Profile and optimize your code to speed up your programs
- Apply design patterns to your applications
Approach
This book is an authoritative exploration of Python best practices and applications of agile methodologies to Python, illustrated with practical, real-world examples.
Who this book is written for?
This book is for Python developers who are already building applications, but want to build better ones by applying best practices and new development techniques to their projects.
The reader is expected to have a sound background in Python programming.
Product Details
- Amazon Sales Rank: #70206 in Books
- Published on: 2008-09-26
- Original language: English
- Number of items: 1
- Binding: Paperback
- 376 pages
Editorial Reviews
About the Author
Tarek Ziadé is CTO at Ingeniweb in Paris, working on Python, Zope, and Plone technology and on Quality Assurance. He has been involved for 5 years in the Zope community and has contributed to the Zope code itself. Tarek has also created Afpy, the French Python User Group and has written two books in French about Python. He has gave numerous talks and tutorials in French and international events like Solutions Linux, Pycon, OSCON, and EuroPython.
Customer Reviews
lots of good stuff, but many infuriating details
I was very biased in favor of this book to start with -- I got a free review copy, Tarek is a Python committer like me, and I even found myself quoted by name as early as the intro;-). Throughout the book, I kept *wanting* to like it... there ARE plenty of good and useful materials strewn throughout it... but in the end the overall judgment had to be (slightly) negative, because there are just too many infuriating details -- the book's detailed copyediting was clearly something the publishers badly skimped on. I ran out of steam entering errata on the book's site -- there are just too many small errors and not a few not-so-small ones; I didn't even get started on the many, many cases of awkward or outright incorrect English -- clearly the editors of an author who's not a native speaker of English must put particularly care in that (as a non-native speaker and author myself I'm keenly aware of that) and in this case it absolutely wasn't done.
But let's focus on the GOOD stuff: there's a TON of brief but useful summaries of installing and configuring a zillion useful tools (all open source ones which you can freely download from their various sources), from editors to (kinda;-) "linux emulators" for Windows, from automated build and test frameworks to revision control systems both centralized and distributed, and so on. In most cases you'll want to delve deeper into the documentation of specific tools, and of course there are alternative "competing" tools that can are barely mentioned (or not even mentioned), but the vast collection of simple instructions and author's recommendations is quite useful anyway, in many cases even for tasks that _aren't_ related to Python programming.
Almost as useful (and almost as short) is the overview of method for arranging and structuring development, documentation, testing, and optimization -- these parts would be especially useful to students, who typically never get exposed to any of these issues, at all, in college courses on programming and "computer science". Again, you'll want to delve deeper into each subject, but it's a useful thing to have the very basics laid out compactly and logically. Unfortunately, the author has a penchant for _over_simplifying, and particularly for apodictically asserting (with no or insufficient justification) theses and preferences that are far from expert developers' consensus; to get real value out of the book, you need to read it in an extremely critical frame of mind, ready to question each and every assertion with independent research (many you'll find confirmed, many others you won't).
This also holds for the chapter on design patterns, with such egregious claims as "Singletons should not have several levels of inheritance" -- they should have as few as practical and feasible, *exactly like any other class*; the desire to limit the number of distinct instances (which is mostly about STATE) is quite orthogonal to the issues with subclassing (which is mostly about BEHAVIOR). From this original "totally missing the point" follows a classic howler (which I've seen repeated in a review above): "why not use a module?". I have news for you, Tarek: a module supports *ZERO* inheritance -- which is quite a bit stricter than even the unjustified "should not have several level" claim above. Having to completely give up the usefulness of inheritance just because you want to limit instantiation would be a very limiting engineering tradeoff! If there's no need for inheritance then *of course* you want to use a module - DOH! - but if there IS (or if special methods can really help you) then it's not an option.
Some of the Python-specific parts are even weaker -- I was particularly disappointed at the two pages about "how Python deals with memory", which confuse references and objects and thus don't really help the reader at all with this crucial part of "expert Python use". To end on a high note, though, other Python-specific parts here and there are quite useful, and only partly overlap with the contents of other books on the subject -- things such as 'eggs' and testing frameworks such as `nose'. But overall the Python-specific content of this book (particularly the good and useful parts thereof) is surprisingly little for the title, surely less than half.
Overall, I would recommend this book only to a reader who IS prepared for extremely critical reading and double-checking, is not put out by very un-idiomatic English and frequent minor errors (typos in text and code, etc), and who thinks he can get good use out of the best parts of the books, the selective "survey" and summary instructions about many excellent tools and the simplified coverage of development methodologies.
Made concrete improvements to the way I work with Python every day
[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.
Good ideas, poor editing
This is the only book I've found that really talks about Python best practices at length. The author definitely has some good ideas about managing and releasing code, as well as taking advantage of Python's more advanced constructs.
However, there are way too many editing mistakes in here. I understand that English is not the author's primary language, but he should have gotten an editor or reviewer to fix his grammar and punctuation mistakes. More importantly, there are a lot of typos and obvious bugs in the Python code examples used throughout the book. I would recommend the author follow in the footsteps of The Pragmatic Programmer and ensure that all the code in his book actually compiles and runs.




