return a list of numbers and non-numeric substrings of +str+
the numeric substrings are converted to integer, non-numeric are left as is
"""
- if type(str) in types.StringTypes:
+ if type(str) in str:
chunks = re.findall("(\d+|\D+)",str)
#convert numeric strings to numbers
chunks = [re.match('\d',x) and int(x) or x for x in chunks]
return chunks
- elif type(str) in [types.IntType, types.LongType, types.FloatType]:
+ elif type(str) in [int, int, float]:
return [str]
else:
raise ValueError("Unsupported type %s for input %s" % (type(str), str))