Skip to content
Snippets Groups Projects
Commit 0427a20e authored by Phil's avatar Phil
Browse files

Added default random size parameter to RandString and RandBin classes (at last!)

parent b870bc40
No related branches found
No related tags found
No related merge requests found
......@@ -144,9 +144,11 @@ class RandChoice(RandField):
return random.choice(self._choice)
class RandString(RandField):
def __init__(self, size, chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"):
self.chars = chars
def __init__(self, size=None, chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"):
if size is None:
size = RandNumExpo(0.01)
self.size = size
self.chars = chars
def _fix(self):
s = ""
for i in range(self.size):
......@@ -154,7 +156,7 @@ class RandString(RandField):
return s
class RandBin(RandString):
def __init__(self, size):
def __init__(self, size=None):
RandString.__init__(self, size, "".join(map(chr,range(256))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment