pyclbr can scan Python source to find classes and stand-alone functions. The information about class, method, and function names and line numbers is gathered using tokenize without importing the code.
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.
The timeit module provides a simple interface for determining the execution time of small bits of Python code. It uses a platform-specific time function to provide the most accurate time calculation possible and reduces the impact of start-up or shutdown costs on the time calculation by executing the code repeatedly.
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.
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.
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.
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.
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.
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 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.
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.