Does "with changing internal structures" mean that list in not always one level deep as in "inputlist"?
If list is only one level deep simple brute-force conversion should suffice. One possibility:
If list is only one level deep simple brute-force conversion should suffice. One possibility:
>>> inputlist=['Cities',14,'WACC',(32,'KHI',208.55567),['Stat',14,'RS0']] >>> outputlist = list() >>> for el in inputlist: ... obj_type = type(el) ... if isinstance(el, (list, tuple)): # alternatively: if obj_type in [tuple, list]: ... outputlist.append([str(x) for x in el]) ... if obj_type == tuple: ... outputlist[-1] = obj_type(outputlist[-1]) ... else: ... outputlist.append(str(el)) ... >>> outputlist ['Cities', '14', 'WACC', ('32', 'KHI', '208.55567'), ['Stat', '14', 'RS0']]
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.