aboutsummaryrefslogtreecommitdiff
path: root/gn3/random.py
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2021-08-31 11:16:29 +0300
committerMuriithi Frederick Muriuki2021-08-31 11:16:29 +0300
commitb5e1d1176f1bf4f7c0b68b27beb15e99418f1650 (patch)
treef158a54b262214ca65394a7dc65a64590533cc0c /gn3/random.py
parente441509a59c20a051fd5ab94710513f1968a5e02 (diff)
downloadgenenetwork3-b5e1d1176f1bf4f7c0b68b27beb15e99418f1650.tar.gz
Fix linting errors, minor bugs and reorganise code
* Fix some linting errors and some minor bugs caught by the linter. Move the `random_string` function to separate module for use in multiple places in the code.
Diffstat (limited to 'gn3/random.py')
-rw-r--r--gn3/random.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/gn3/random.py b/gn3/random.py
new file mode 100644
index 0000000..f0ba574
--- /dev/null
+++ b/gn3/random.py
@@ -0,0 +1,11 @@
+"""
+Functions to generate complex random data.
+"""
+import random
+import string
+
+def random_string(length):
+ """Generate a random string of length `length`."""
+ return "".join(
+ random.choices(
+ string.ascii_letters + string.digits, k=length))