Last active
February 15, 2018 01:28
-
-
Save crock/9c6953d1a399a7e487514cd6f114253b to your computer and use it in GitHub Desktop.
My personal collection of utility functions for Python
This file contains 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 characters
import string | |
import random | |
class accorelib: | |
"""My personal collection of utility functions""" | |
def __init__(self): | |
print("accorelib initialized...") | |
def debug(self, message): | |
"""Prints out debug message to console | |
Arguments: | |
message {string} -- the debug message | |
""" | |
print("\n[DEBUG] %s\n" % message) | |
def hash(self, size=16, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase): | |
"""Generate a strong, randomized string that could be used for a password | |
Keyword Arguments: | |
size {integer} -- Length of string (default: {16}) | |
chars {list} -- what characters to include (default: {string}) | |
""" | |
return ''.join(random.choice(chars) for _ in range(size)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment