<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def errdev(op, lenout, device):
 """ Retrieve or set the name of the current output device for error messages. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/errdev_c.html :param op: The operation, "GET" or "SET". :type op: str :param lenout: Length of device for output. :type lenout: int :param device: The device name. :type device: str :return: The device name. :rtype: str """

    lenout = ctypes.c_int(lenout)
    op = stypes.stringToCharP(op)
    device = ctypes.create_string_buffer(str.encode(device), lenout.value)
    deviceptr = ctypes.c_char_p(ctypes.addressof(device))
    libspice.errdev_c(op, lenout, deviceptr)
    return stypes.toPythonString(deviceptr)