<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def timdef(action, item, lenout, value=None):
 """ Set and retrieve the defaults associated with calendar input strings. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/timdef_c.html :param action: the kind of action to take "SET" or "GET". :type action: str :param item: the default item of interest. :type item: str :param lenout: the length of list for output. :type lenout: int :param value: the optional string used if action is "SET" :type value: str :return: the value associated with the default item. :rtype: str """

    action = stypes.stringToCharP(action)
    item = stypes.stringToCharP(item)
    lenout = ctypes.c_int(lenout)
    if value is None:
        value = stypes.stringToCharP(lenout)
    else:
        value = stypes.stringToCharP(value)
    libspice.timdef_c(action, item, lenout, value)
    return stypes.toPythonString(value)