I think the problem space is not well defined for such a method to exist. Some transformations will be destructive, and some may take place in more than one way. A few examples:
>>> list(set([1,2,2,3])) [1, 2, 3] >>> list("hello") ['h', 'e', 'l', 'l', 'o'] >>> ["hello"] ['hello'] >>> list({'a':1, 'b': 2}) ['a', 'b'] >>> list({'a':1, 'b': 2}.iteritems()) [('a', 1), ('b', 2)]
For an argument, you can also convert the string to any type of Python using eval() .
So basically it all depends on your use case.
If you really want to do a more comprehensive search, you can use the types module to get a list of built-in types, and then try to cross-convert (provided that you can get instances of each of them)
>>> import types >>> [types.__dict__.get(t) for t in dir(types) if t.endswith('Type')] [<type 'bool'>, <type 'buffer'>, <type 'builtin_function_or_method'>, <type 'builtin_function_or_method'>, <type 'classobj'>, <type 'code'>, <type 'complex'>, <type 'dictproxy'>, <type 'dict'>, <type 'dict'>, <type 'ellipsis'>, <type 'file'>, <type 'float'>, <type 'frame'>, <type 'function'>, <type 'generator'>, <type 'getset_descriptor'>, <type 'instance'>, <type 'int'>, <type 'function'>, <type 'list'>, <type 'long'>, <type 'member_descriptor'>, <type 'instancemethod'>, <type 'module'>, <type 'NoneType'>, <type 'NotImplementedType'>, <type 'object'>, <type 'slice'>, <type 'str'>, <type 'traceback'>, <type 'tuple'>, <type 'type'>, <type 'instancemethod'>, <type 'unicode'>, <type 'xrange'>]
I do not know if you need to create a supported_conversions dictionary in advance. Assuming you always convert intype to outtype on outtype(intype_value) , you can try this and then update the dictionary that displays (intype, outtype) -> bool and therefore it will not try to perform the conversion again if it fails for the first time.