def check_length ( value , length ) : _length = len ( value ) if _length != length : raise ValueError ( "length must be %d, not %d" % ( length , _length ) )
python check len of value
Checks length of value
def check_length(value, length):
    """
    Checks length of value

    @param value: value to check
    @type value: C{str}

    @param length: length checking for
    @type length: C{int}

    @return: None when check successful

    @raise ValueError: check failed
    """
    _length = len(value)
    if _length != length:
        raise ValueError("length must be %d, not %d" % \
                         (length, _length))