The time module provides access to several different types of clocks, each useful for different purposes. The standard system calls like time() report the system “wall clock” time. The monotonic() clock can be used to measure elapsed time in a long-running process because it is guaranteed never to move backwards, even if the system time is changed. For performance testing, perf_counter() provides access to the clock with the highest available resolution to make short time measurements more accurate.
The struct module includes functions for converting between strings of bytes and native Python data types such as numbers and strings.
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.
This year marks the 10th anniversary of the first post for the Python Module of the Week series. What started as an exercise to push myself to write on a regular basis has, thanks to all of you, evolved into a much more long-lived and popular endeavor than I ever expected. A project of this scope is truly a group effort, and I have been fortunate to find good people to work with.
The zipfile module can be used to manipulate ZIP archive files, the format popularized by the PC program PKZIP.
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.
Regular expressions are text matching patterns described with a formal syntax. The patterns are interpreted as a set of instructions, which are then executed with a string as input to produce a matching subset or modified version of the original. The term “regular expressions” is frequently shortened to as “regex” or “regexp” in conversation. Expressions can include literal text matching, repetition, pattern-composition, branching, and other sophisticated rules. A large number of parsing problems are easier to solve with a regular expression than by creating a special-purpose lexer and parser.
The string module dates from the earliest versions of Python. Many of the functions previously implemented in the module have been moved to methods of str objects. The string module retains several useful constants and classes for working with str objects, and this discussion will concentrate on them.
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 gzip module provides a file-like interface to GNU zip files, using zlib to compress and uncompress the data.
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.
Last week at the OpenStack Forum in Boston, the Release Team gave an onboarding orientation session with the goal of attracting new contributors to the team.
While Python is the “Batteries Included” programming language and comes with a wide variety of modules in the standard library, there are even more libraries, frameworks, and tools available to be installed from the Python Package Index . To install those packages, a developer needs the installer tool pip . Installing a tool meant to install tools presents an interesting bootstrapping issue, which ensurepip solves.
Read more…
This post is part of the Python Module of the Week series for Python 3.