More concise than others:
def parseString(string): try: return int(string) except ValueError: return string b = [[parseString(s) for s in clause.split(', ')] for clause in a]
Alternatively, if your format is fixed as <string>, <int>, <int> , you can be more concise:
def parseClause(a,b,c): return [a, int(b), int(c)] b = [parseClause(*clause) for clause in a]
ninjagecko
source share