skip to navigation
skip to content

Not Logged In

dhp 0.0.12

A collection of handy modules, almost guaranteed to get you into trouble.

dhp is a library of snippets almost guaranteed to get you into trouble.

I obtained it from a vendor, on the corner, outside of PyCon.

Actually, this is a growing repository of routines that I find helpful from time to time. I think you might too.

Example Phrasebook Contents

See the Full Documentation for a complete listing.


  • DOQ Data Object Query mapper. Query simple data sources with an ORM like style.
from dhp.doq import DOQ

doq = DOQ(data_objects=data_source)
for rec in doq.filter(occupation='Publisher'):


  • DictDot - subclasses Python’s built-in dict object and offers attribute access to the dictionary.
from dhp.structures import DictDot

my_dict = {'hovercraft': 'eels', 'speed': 42}
dicdot = DictDot(my_dict)
assert dicdot.hovercraft == 'eels'
assert dicdot.speed == 42


  • tempfile_containing - generate a temporary file that contains indicated contents and returns the filename for use. When finished the tempfile is removed.
from dhp.test import tempfile_containing

contents = 'I will not buy this record, it is scratched.'
with tempfile_containing(contents) as fname:


  • xml_to_dict - parse any ugly xml to a python dictionary.
from dhp.xml import xml_to_dict

xml = '<vehicle type="Hovercraft"><filled/><cargo>eels</cargo></vehicle>'

{'vehicle': {'@type':'Hovercraft',
             'filled': None}


Tested on Python 2.7, 3.2, 3.3, 3.4




Make sure to get the latest version.

pip install dhp


Full Docs

File Type Py Version Uploaded on Size
dhp-0.0.12.tar.gz (md5) Source 2015-09-28 12KB
  • Downloads (All Versions):
  • 63 downloads in the last day
  • 310 downloads in the last week
  • 1459 downloads in the last month