Please create an account to participate in the Slashdot moderation system


Forgot your password?
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 internet speed test! ×

Submission + - The Python Standard Library by Example (

thatpythonguy writes: "Addison-Wesley publishers bring you another Python book that strategically fits in between programming cookbooks and library reference manuals. It brings the Python standard library that much closer to Python programmers and helps make them more proficient in their trade.

There has been an explosion in the availability of published titles for the Python programming language in the past few years. This has been driven by the rising popularity of this multi-paradigm language that has proven useful in domains spanning web, games, graphics, financial, science, automation and others. Many large and small corporations, universities and governmental organizations are using Python in their respective fields with seeming success.

One of the main reasons for the success of Python is the quality, breadth, and depth of its standard library. Unfortunately, this library is not documented sufficiently in titles that serve as introductory or reference material due to the nature of introductory texts that deal with the basics; on the other hand, reference texts are often too concise and lack sufficient examples. The title at hand is a library-centric tutorial/reference that can be a great tool when you need to learn how to solve certain problems using Python.

The book addresses itself to intermediate Python programmers and covers versions 2.7 and 3.x of the language. Although an experienced programmer coming from another language can learn a lot about Python by reading this book, I personally favor the traditional top-down, gradual method of learning a new language which involves an introductory, tutorial-style, and verbose introductory book. However, realizing that others might not like my cup of tea, I can envision, for example, someone familiar with socket programming picking up this book and writing a network application without prior Python experience. He or she might still need to look up language features on the way, but that should not be too hard as the language is easy to understand and there is a rich library of on-line (and printed) content for basic language constructs.

This title comes in a hefty 1300-plus-page, soft-cover book (or eBook) that is organized around thematic grouping of library modules. The groups are: text, data structures, algorithms, dates and times, mathematics, file system, data persistence and exchange, data compression and archiving, cryptography, processes and threads, networking, the Internet, email, application building blocks, internationalization and localization, developer tools, runtime features, language tools, modules and packages.

Each group contains the relevant modules from the standard library. For example, the text group contains the string, textwrap, re and difflib modules. Each of these modules is briefly described first and then its use is demonstrated in various ways under an appropriate heading. For example, the socket module (networking group) has sections covering addressing, TCP/IP client/Server, UDP clients/servers, UNIX domain sockets and multicast, among others. The code is written in such a way as to focus on the topic being discussed while not overlooking good practices such as wrapping a socket connection call with a try/finally block to ensure that the connection is closed in case of error.

A more advanced module, that is also described in the networking group, is SocketServer. This is a higher-level (on top of the socket layer) facility that enables the creation of network servers (e.g., HTTP or AMQP). It is nice to see that the book demonstrates the creation of an echo server using this module while incorporating more advanced topics such as threading and asynchronous I/O which are necessities in real-life, production code.

Although the content covers quite a bit of ground that surpasses many other sources in terms of coverage, the Python standard library is so vast that any one-volume book attempting to provide comprehensive coverage will necessarily fail! Nonetheless, you will find at the end of each section pointers to other material such as on-line resources, RFCs, and related books that can be used for a deeper study of the relevant topics.

I think that the text could use some typographical features to enhance the clarity of the content. These include highlighting the code using indents or an alternative font to set it apart from the text that surrounds it as I found it hard to visually distinguish the two. The code should also have the name of the file at the top of the listing so that when that name is used subsequently to invoke the code, it would be easy to reference the file contents. Also,I find the general typesetting not as pleasing nor as easy to read as titles from certain other publishers. This latter point is somewhat subjective and, in any case, does not detract from the utility of the content.

Despite the caveat above, I have to say that I like this class of documentation that is between a cookbook and a reference manual. I find it useful that the examples are not so terse nor overly verbose. I also appreciate the quality of the code and the references for further readings. I think that this book fills a void that will make many Python programmers more proficient.

Ahmed Al-Saadi is the Principal Software Consultant for Solea Research, a software consultancy and development company based in Montreal, Canada. He spends his free time writing, contemplating software architecture and playing his Flamenco guitar.


This discussion was created for logged-in users only, but now has been archived. No new comments can be posted.

The Python Standard Library by Example

Comments Filter:

You can write a small letter to Grandma in the filename. -- Forbes Burkowski, CS, University of Washington