You are doing some very funky stuff there that is totally not necessary.
This loop is your problem:
for y, item in enumerate(store):
setattr(sys.modules[__name__], 'v{0}'.format(y), item)
You are setting the same 5 global variables over and over again, overwriting the previous version. Your use of setattr(sys.modules[__name__], ..)
is totally not needed when you have the globals()
function giving you the global namespace as a dictionary. But setting global variables to solve a simple problem is like using a shotgun to catch one gnat.
Your code could be vastly simplified:
def main(self, count):
seq = "ABCDFGHJIKLMNOPQRSTUVWXYZ1234567890"
for i in range(count):
print('-'.join(''.join(random.choice(seq) for _ in range(5)) for _ in range(5)))
print("\nCreated {} serial keys!".format(count))
Sample printed output for count
set to 5:
LWLGX-F6MNR-9YIZC-H23TK-TIGB9
YALYY-4ZARO-8H9BV-YMHVD-HFFGP
JNA5R-65GT1-TZ3BM-PNMZI-56NM3
39VCY-MLZ98-SU1PP-PYMX7-RZJQZ
76LGC-VF5MG-LK7C4-XPUSO-H0B97