def __getitem__(self, key):
        '''grab item from dictionary if it exists, otherwise try prefixes'''
        if key in self.units:
            return self.units[key]
        else:
            if len(key)==1: # don't look for prefix if one letter unit
                raise DimensionsError, 'unit %s not found' % key
            for prefix in self.prefixes:
                if key.startswith(prefix):
                    return self.prefixes[prefix]*self.units[key[len(prefix):]]
            raise DimensionsError, 'unit %s not found' % key
grab item from dictionary if it exists, otherwise try prefixes
recipes/Python/577333_Numerical_type_units/recipe-577333.py