make randomString work not only with indexable containers
@@ -40,7 +40,7 @@ Seconds = TypeVar("Seconds", int, float)
def randomString(size: int = 20,
- chars: str = string.ascii_letters + string.digits) -> str:
+ chars = string.ascii_letters + string.digits) -> str:
"""
Generate a random string of the specified size
@@ -49,6 +49,10 @@ def randomString(size: int = 20,
:return: the random string generated
"""
+ if not hasattr(chars, "__getitem__"):
+ # choice does not work with non indexed containers
+ chars = list(chars)
+
def randomChar():
return random.choice(chars)
