X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=blobdiff_plain;f=htsworkflow%2Futil%2Falphanum.py;h=9413f492248cfc8d4f8e9b49f1b0206c9079bc12;hp=c9d66495e76fe672a5c41019ce378358c4ee736b;hb=refs%2Fheads%2Fpython3-django1.5;hpb=4262586d10cc0cc227390873b301b55244204c11 diff --git a/htsworkflow/util/alphanum.py b/htsworkflow/util/alphanum.py index c9d6649..9413f49 100644 --- a/htsworkflow/util/alphanum.py +++ b/htsworkflow/util/alphanum.py @@ -35,12 +35,12 @@ def chunkify(str): 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))