Generates a random string of upper and lowercase letters.
        :type min_chars: int
        :type max_chars: int
        :return: String. Random of random length between min and max characters.
427953
def pystr(self, min_chars=None, max_chars=20):
        
        if min_chars is None:
            return "".join(self.random_letters(length=max_chars))
        else:
            assert (
                max_chars >= min_chars), "Maximum length must be greater than or equal to minium length"
            return "".join(
                self.random_letters(
                    length=self.generator.random.randint(min_chars, max_chars),
                ),
            )
815013
def random_string(length=6, alphabet=string.ascii_letters+string.digits):
    
    return ''.join([random.choice(alphabet) for i in xrange(length)])
200328
def generate(self, minlen, maxlen):
        
        if minlen < 1 or maxlen < minlen:
            raise ValueError()

        for cur in range(minlen, maxlen + 1):
            # string product generator
            str_generator = product(self.charset, repeat=cur)
            for each in str_generator:
                # yield the produced word
                yield ''.join(each)+self.delimiter
514312
def randstr(self):
        
        return gen_rand_str(
            4, 10, use=self.random, keyspace=list(string.ascii_letters))
419938
def get_rand_string(length=12, allowed_chars='0123456789abcdef'):
    
    if not using_sysrandom:
        # This is ugly, and a hack, but it makes things better than
        # the alternative of predictability. This re-seeds the PRNG
        # using a value that is hard for an attacker to predict, every
        # time a random string is required. This may change the
        # properties of the chosen random sequence slightly, but this
        # is better than absolute predictability.
        random.seed(
            hashlib.sha256(
                ("%s%s" % (
                    random.getstate(),
                    time.time())).encode('utf-8')
            ).digest())
    return ''.join([random.choice(allowed_chars) for i in range(length)])
1058702
def gen_random_string(str_len):
    
    return ''.join(
        random.choice(string.ascii_letters + string.digits) for _ in range(str_len))
140195
def random_hex(length):
    
    charset = ''.join(set(string.hexdigits.lower()))
    return random_string(length, charset)
436412
def generate_password(length=32):
    
    return ''.join(random.SystemRandom().choice(string.ascii_letters + '!@#$+.,') for _ in range(length))
870508
def generate_password():
    
    chars = uppercase + lowercase + digits
    return ''.join(SystemRandom().choice(chars) for x in xrange(16))
12488
def random_letters(count):
    """"""
    rv = random.choice(string.ascii_uppercase)
    while len(rv) < count:
        l = random.choice(string.ascii_uppercase)
        if not l in rv:
            rv += l
    return rv
485626
def randomize(length=6, choices=None):
    """"""
    if type(choices) == str:
        choices = list(choices)
    choices = choices or ascii_lowercase
    return "".join(choice(choices) for _ in range(length))
1334960
def random_str(size=10):
    
    return ''.join(random.choice(string.ascii_lowercase) for _ in range(size))
765029
def random_string(length, charset):
    
    n = len(charset)
    return ''.join(charset[random.randrange(n)] for _ in range(length))
732606
def get_random_string():
    
    
    # set up a random string to associate with the run
    hash_string = "%8x" % random.getrandbits(32)
    hash_string = hash_string.strip()
    
    # done't allow the random strings to be equivalent to a number, since
    # the LSF cluster interprets those differently from letter-containing
    # strings
    while is_number(hash_string):
        hash_string = "%8x" % random.getrandbits(32)
        hash_string = hash_string.strip()
    
    return hash_string
694444
def simulate(self):
        
        min_ = 1 if self._min is None else self._min
        max_ = 10 if self._max is None else self._max
        n = min_ if (min_ >= max_) else random.randint(min_, max_)
        chars = string.ascii_letters + string.digits
        return ''.join(random.choice(chars) for x in range(n))
673287
def rand_ascii_str(length):
    
    letters = [random.choice(ascii_letters_and_digits) for _ in range(length)]
    return ''.join(letters)
404905
def generate_random_type(valid):
    
    type = choice(['int', 'str'])

    r = lambda: randrange(-1000000000, 1000000000)

    if type == 'int':
        return int,  (r() if valid else str(r()) for i in itertools.count())
    elif type == 'str':
        return str, (str(r()) if valid else r() for i in itertools.count())
    else:
        raise AssertionError('!')