Last active
October 21, 2018 20:36
-
-
Save molcay/40017e8d170c28d99e632f29ecd633ee to your computer and use it in GitHub Desktop.
Revisions
-
molcay revised this gist
Oct 21, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,4 +30,4 @@ def generate_from_pattern(self, pattern, sep=' '): uuid_format = [8, 4, 4, 4, 12] rnd = Random() uuid_with_all_ascii_letters_and_digits = rnd.generate_from_pattern(uuid_format, '-') print(uuid_with_all_ascii_letters_and_digits) -
molcay created this gist
Oct 21, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ import random as r import string def randomized_default(): domains = [string.ascii_uppercase, string.ascii_lowercase, string.digits] r.shuffle(domains) as_list = list(''.join(domains)) r.shuffle(as_list) return ''.join(as_list) class Random: _default_str_seq = randomized_default() def __init__(self, str_seq=_default_str_seq): self.str_seq = str_seq def generate_from_pattern(self, pattern, sep=' '): random_str_parts = [] for part in pattern: str_part = "" for i in range(0, part): str_part += str(r.choice(self.str_seq)) random_str_parts.append(str_part) return sep.join(random_str_parts) uuid_format = [8, 4, 4, 4, 12] rnd = Random() uuid_with_all_ascii_letters_and_digits = rnd.generate_from_pattern(uuid_format, '-') print(a)