class Zdic(dict):
    """ A dictionary-like object that return 0 when a user
        request a non-existant key.
   
    """
   
    def __missing__(self,x):
        return 0

This code is part of the book "Python for Bioinformatics", by Sebastian Bassi (sbassi@genesdigitales.com). Return to home page.