<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_string(string, mime=False, filename=None):
 """ Reads in string, attempts to identify content based off magic number and will return the file extension. If mime is True it will return the mime type instead. If filename is provided it will be used in the computation. :param string: string representation to check :param mime: Return mime, not extension :param filename: original filename :return: guessed extension or mime """

    head, foot = _string_details(string)
    ext = ext_from_filename(filename) if filename else None
    return _magic(head, foot, mime, ext)