def is_read_only ( object ) : try : attribute = "_trace__read__" setattr ( object , attribute , True ) delattr ( object , attribute ) return False except ( TypeError , AttributeError ) : return True
python read only mode
Returns if given object is read only ( built - in or extension ) .
def is_read_only(object):
    """
    Returns if given object is read only ( built-in or extension ).

    :param object: Object.
    :type object: object
    :return: Is object read only.
    :rtype: bool
    """

    try:
        attribute = "_trace__read__"
        setattr(object, attribute, True)
        delattr(object, attribute)
        return False
    except (TypeError, AttributeError):
        return True