lib.common.rand

Package lib :: Package common :: Module rand |
[hide private]
[frames] | no frames]

# Source Code for Module lib.common.rand

     1  import random
     2  import string
     3
     4 -def random_string(minimum, maximum=None):
     5      if maximum is None:
     6          maximum = minimum
     7
     8      count = random.randint(minimum, maximum)
     9      return "".join(random.choice(string.ascii_letters) for x in xrange(count))
    10
    11 -def random_integer(digits):
    12      start = 10 ** (digits - 1)
    13      end = (10 ** digits) - 1
    14      return random.randint(start, end)
    15