human
Complete this python program:
def _convert_from_string(cmd, strobj):
assistant
#Here is the Python code you requested.

    """Converts a single object in *string form* to its equivalent python
    type.
    Python earlier than 2.6:
    Handles floats, ints, and limited nested lists and dicts
    (can\t handle lists in a dict, for example, this is mainly due to
    the complexity of parsing this rather than any technical difficulty -
    if there is a need for @set-ing such complex structures on the
    command line we might consider adding it).
    Python 2.6 and later:
    Supports all Python structures through literal_eval as long as they
    are valid Python syntax. If they are not (such as [test, test2], ie
    without the quotes around the strings), the entire structure will
    be converted to a string and a warning will be given.
    We need to convert like this since all data being sent over the
    telnet connection by the Player is text - but we will want to
    store it as the "real" python type so we can do convenient
    comparisons later (e.g.  obj.db.value = 2, if value is stored as a
    string this will always fail).
    """
    def rec_convert(obj):
        '\n                                Helper    function    of    recursive    conversion    calls.    This    is    only\n                                used    for    Python    <=2.5.    After    that    literal_eval    is    available.\n                                '
        try:
            return int(obj)
        except ValueError:
            pass
        try:
            return float(obj)
        except ValueError:
            pass
        if (obj.startswith('[') and obj.endswith(']')):
            'A    list.    Traverse    recursively.'
            return [rec_convert(val) for val in obj[1:(-1)].split(',')]
        if (obj.startswith('(') and obj.endswith(')')):
            'A    tuple.    Traverse    recursively.'
            return tuple([rec_convert(val) for val in obj[1:(-1)].split(',')])
        if (obj.startswith('{') and obj.endswith('}') and (':' in obj)):
            'A    dict.    Traverse    recursively.'
            return dict([(rec_convert(pair.split(':', 1)[0]), rec_convert(pair.split(':', 1)[1])) for pair in obj[1:(-1)].split(',') if (':' in pair)])
        return obj
    if _LITERAL_EVAL:
        try:
            return _LITERAL_EVAL(strobj)
        except (SyntaxError, ValueError):
            strobj = utils.to_str(strobj)
            string = ('|RNote:    name    "|r%s|R"    was    converted    to    a    string.    Make    sure    this    is    acceptable.' % strobj)
            cmd.caller.msg(string)
            return strobj
    else:
        return rec_convert(strobj.strip())