def safe_repr ( obj ) : name = getattr ( obj , '__name__' , getattr ( obj . __class__ , '__name__' ) ) if name == 'ndict' : name = 'dict' return name or repr ( obj )
setting the default python interprter
Try to get __name__ first __class__ . __name__ second and finally if we can t get anything acceptable fallback to user a repr () call .
def safe_repr(obj):
    """
    Try to get ``__name__`` first, ``__class__.__name__`` second
    and finally, if we can't get anything acceptable, fallback
    to user a ``repr()`` call.
    """
    name = getattr(obj, '__name__', getattr(obj.__class__, '__name__'))
    if name == 'ndict':
        name = 'dict'
    return name or repr(obj)