Snippet of code that uses recursion to print nested dictionaries.
It does not sort the entries!
Diff two dictionaries returning just the differences. If an item is not found, it is represented by the string "<KEYNOTFOUND>". If there is a better way, please share. :)
One of the most frequently asked questions is how to efficiently get a list of Python dictionaries from a database query rather than the difficult-to-use list of tuples.
The recipe illustrates the composite design pattern by using hierarchical dictionaries. It can be used to process hierarchical, tree-based data structures using Python dictionaries.
Sometimes, especialy if you are working with database object mappers, you encounter deeply nested dictionaries. You want to access a particular leaf item and you have in your hand the long, decorated, name. reduce can be your friend!
some while ago, i posted a recipe with linked dictionaries (see <a href='http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/465748'>#465748</a>) to this site. yesterday a use case came up where that kind of delegational name/value...
Linked dictionaries are dictionaries that can refer to other dictionaries (its bases), similar to class hierarchies, but built at runtime. A linked dictionary shows all the key/value pairs that are defined locally (in the very instance) and...
This is a PHP web application for creating custom Scale, Chord and Interval dictionaries and diagrams for any musical instrument.
MySQL database tables enumerates all possible scales, chords and intervals (in the 12TET Universe) and...
This project offers galician dictionaries for several spell checkers: "Ispell", "Myspell" , "Aspell", "Spell Checker for Edit Boxes" and "Excalibur".
An implementation of dictionaries preserving key insertion order. Despite using a doubly-linked list to keep track of the appropriate order, this list is actually embedded in the dictionary. As a consequence, there is little space penalty, and...
Set-like operations for dictionaries
Easy to use chain of dictionaries for crafting nested scopes or for a tree of scopes. Useful for analyzing AST nodes, XML nodes or other structures with multiple scopes. Can emulate various chaining styles including static/lexical scoping,...
An Easy way to Marshal Data In Python By Sending Dictionaries of Python Data To And From Client/Server Solutions. Can Be Used In A Lot Of Ways in XmlRpc, HTTP/HTTPS Posts, RAW Sockets etc.
A very simple specialization of the dictionary that makes it possible to merge two dictionaries provided that they are compatible : if a given key is present in both dictionaries, it must be associated with the same value.
Shelving dictionaries are quick and easy, until they grow too large and access is slowed to a crawl. This recipe is a directory cache with the filename an md5 of the key and the value is the file contents (as a pickled dump).
This recipe provides an alternative way of generating and updating dictionaries. It savs couple of keystrokes, making routine dict operations easier.
Invert different types of dictionaries with mixed data types as values.
Python's lack of a 'switch' statement has garnered much discussion and even a PEP. The most popular substitute uses dictionaries to map cases to functions, which requires lots of defs or lambdas. While the approach shown here may be O(n) for...
Reads an xml file into a python dictionary of dictionaries (repeated elements are read in as lists).
Modified from xmlreader.py by Christoph Dietze - differs in not needing repeated elements to be tagged in the xml file.
A function similar to the builtin reduce for reducing dictionaries.