some updates

This commit is contained in:
Miroslav Stampar
2010-10-11 12:26:35 +00:00
parent 8b0a132fa9
commit 43892cddbb
6 changed files with 31 additions and 5 deletions

View File

@@ -551,7 +551,7 @@ def randomInt(length=4):
return int("".join([random.choice(string.digits) for _ in xrange(0, length)]))
def randomStr(length=4, lowercase=False):
def randomStr(length=4, lowercase=False, alphabet=None):
"""
@param length: length of the random string.
@type length: C{int}
@@ -560,7 +560,9 @@ def randomStr(length=4, lowercase=False):
@rtype: C{str}
"""
if lowercase:
if alphabet:
rndStr = "".join([random.choice(alphabet) for _ in xrange(0, length)])
elif lowercase:
rndStr = "".join([random.choice(string.lowercase) for _ in xrange(0, length)])
else:
rndStr = "".join([random.choice(string.letters) for _ in xrange(0, length)])