<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_length_and_key(fp, value):
 """ Helper to write descriptor key. """

    written = write_fmt(fp, 'I', 0 if value in _TERMS else len(value))
    written += write_bytes(fp, value)
    return written