trace — Follow Program Flow — PyMOTW 3

The trace module is useful for understanding the way a program runs. It watches the statements executed, produces coverage reports, and helps investigate the relationships between functions that call each other.

Read more…

This post is part of the Python Module of the Week series for Python 3. See PyMOTW.com for more articles from the series.

pydoc — Online Help for Modules — PyMOTW 3

The pydoc module imports a Python module and uses the contents to generate help text at runtime. The output includes docstrings for any objects that have them, and all of the classes, methods, and functions of the module are described.

Read more…

This post is part of the Python Module of the Week series for Python 3. See PyMOTW.com for more articles from the series.

multiprocessing — Manage Processes Like Threads — PyMOTW 3

The multiprocessing module includes an API for dividing work up between multiple processes based on the API for threading . In some cases multiprocessing is a drop-in replacement, and can be used instead of threading to take advantage of multiple CPU cores to avoid computational bottlenecks associated with Python’s global interpreter lock.

Read more…

This post is part of the Python Module of the Week series for Python 3. See PyMOTW.com for more articles from the series.

signal — Asynchronous System Events — PyMOTW 3

Signals are an operating system feature that provide a means of notifying a program of an event, and having it handled asynchronously. They can be generated by the system itself, or sent from one process to another. Since signals interrupt the regular flow of the program, it is possible that some operations (especially I/O) may produce errors if a signal is received in the middle.

Read more…

This post is part of the Python Module of the Week series for Python 3. See PyMOTW.com for more articles from the series.

subprocess — Spawning Additional Processes — PyMOTW 3

The subprocess module supports three APIs for working with processes. The run() function, added in Python 3.5, is a high-level API for running a process and optionally collecting its output. The functions call() , check_call() , and check_output() are the former high-level API, carried over from Python 2. They are still supported and widely used in existing programs. The class Popen is a low-level API used to build the other APIs and useful for more complex process interactions. The constructor for Popen takes arguments to set up the new process so the parent can communicate with it via pipes. It provides all of the functionality of the other modules and functions it replaces, and more. The API is consistent for all uses, and many of the extra steps of overhead needed (such as closing extra file descriptors and ensuring the pipes are closed) are “built in” instead of being handled by the application code separately.

Read more…

This post is part of the Python Module of the Week series for Python 3. See PyMOTW.com for more articles from the series.

sched — Timed Event Scheduler — PyMOTW 3

The sched module implements a generic event scheduler for running tasks at specific times. The scheduler class uses a time function to learn the current time, and a delay function to wait for a specific period of time. The actual units of time are not important, which makes the interface flexible enough to be used for many purposes.

Read more…

This post is part of the Python Module of the Week series for Python 3. See PyMOTW.com for more articles from the series.

logging — Report Status, Error, and Informational Messages — PyMOTW 3

The logging module defines a standard API for reporting errors and status information from applications and libraries. The key benefit of having the logging API provided by a standard library module is that all Python modules can participate in logging, so an application’s log can include messages from third-party modules.

Read more…

This post is part of the Python Module of the Week series for Python 3. See PyMOTW.com for more articles from the series.

Book Review: “A Mind at Play”

A Mind At Play by Jimmy Soni and Rob Goodman should be on every techie’s gift list this year because it is superb and because everyone in a technology or information field should know who Claude Shannon is.

When Jimmy Soni offered me a review copy of this new biography of Claude Shannon, I immediately said yes. I knew a little about Shannon from reading The Idea Factory and The Information, and I was looking forward to learning more. The results in A Mind At Play are just what I hoped for.

Soni and Goodman do an excellent job of presenting Shannon’s technical work  to a mostly lay audience, although there is enough depth (and footnotes) to allow you to dig deeper if you are interested. The explanation of his information theory work is clearly laid out and builds from the simplifying model of how communication works to the stochastic analysis of letter frequency and redundancy to finally reach the description of the Shannon limit on the communication speed over any medium. They also cover his contributions in other fields like genetics and mathematics.

The technical sections are interspersed with anecdotes from his life, from his education through his career at Bell Labs and MIT, showing how his continual “constructive dissatisfaction” with the state of the world served as a motivating force in his exploration of a wide range of topics. He set his own course and focused on the things he wanted to, and was privileged to have the freedom to do so. While some of the topics seemed like play, his work always exposed something new; at least to him.

For more details, download this interview with the authors on the Software Engineering Daily podcast.