Last active
August 29, 2015 14:00
-
-
Save aniljava/11269842 to your computer and use it in GitHub Desktop.
PYTHON MASTER LIST OF UTILS
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 characters
# UUID | |
import uuid | |
get_uuid = lambda:uuid.uuid4() | |
# get_id, string_to_id | |
toid = lambda data: ''.join(['_', k.lower()][k in '0123456789-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'] for k in data) | |
# subfolder distribution | |
import os | |
get_path_x = lambda file_name: os.path.join('root_folder', file_name[:4], file_name) | |
get_path = lambda root: lambda file_name: os.path.join(root, file_name[:4], file_name) | |
example = get_path_x('filename.txt') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment