uuid — Universally Unique Identifiers — PyMOTW 3

RFC 4122 defines a system for creating universally unique identifiers for resources in a way that does not require a central registrar. UUID values are 128 bits long and, as the reference guide says, “can guarantee uniqueness across space and time.” They are useful for generating identifiers for documents, hosts, application clients, and other situations where a unique value is necessary. The RFC is specifically focused on creating a Uniform Resource Name namespace and covers three main algorithms:

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 Nothing to Fear

Last week at PyATL I gave an introductory talk about regular expressions. The talk was a bit less pre-written than my usual because I wanted it to be more interactive, so there is no longer blog post to go with the slides but there are some speaker notes. For some similar examples with more code, see PyMOTW: re. The slides are available on my site, via the repository on github, and at the bottom of this post.

Continue reading Regular Expressions Are Nothing to Fear

itertools — Iterator Functions — PyMOTW 3

The functions provided by itertools are inspired by similar features of functional programming languages such as Clojure, Haskell, APL, and SML. They are intended to be fast and use memory efficiently, and also to be hooked together to express more complicated iteration-based algorithms.

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.

getopt — Command Line Option Parsing — PyMOTW 3

The getopt module is the original command line option parser that supports the conventions established by the Unix function getopt() . It parses an argument sequence, such as sys.argv and returns a sequence of tuples containing (option, argument) pairs and a sequence of non-option arguments.

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.

shelve — Persistent Storage of Objects — PyMOTW 3

The shelve module can be used as a simple persistent storage option for Python objects when a relational database is not required. The shelf is accessed by keys, just as with a dictionary. The values are pickled and written to a database created and managed by dbm .

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.