Pattern to integer list function

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def pattern_to_list(self, pattern):
    ret = []

    for e1 in pattern.split(','):
        if e1.strip().isdigit():
            ret.append(int(e1.strip()))
        elif e1.strip().find('-') >= 0:
            s, e = e1.strip().split('-')
            ret += range(int(s.strip()), int(e.strip())+1)

    return ret

More like this

  1. Integer list to pattern function by marinho 5 years, 5 months ago
  2. hide_email by rukeba 5 years ago
  3. SuperChoices by willhardy 4 years, 6 months ago
  4. Scoped Cache Compatible with Django Caching Helpers by axiak 5 years, 2 months ago
  5. Model Choices Helper by pmclanahan 3 years, 3 months ago

Comments

(Forgotten your password?)