From 5dae9ba1784351959a681edb20c4a557437977d1 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 9 Aug 2021 08:46:59 -0700 Subject: [PATCH] Use random.choices instead of random.choice in a loop. --- etiquette/photodb.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index af410b0..1a25129 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -1381,8 +1381,7 @@ class PDBUserMixin: ''' length = self.config['id_length'] for retry in range(20): - user_id = (random.choice(constants.USER_ID_CHARACTERS) for x in range(length)) - user_id = ''.join(user_id) + user_id = ''.join(random.choices(constants.USER_ID_CHARACTERS, k=length)) user_exists = self.sql_select_one('SELECT 1 FROM users WHERE id == ?', [user_id]) if user_exists is None: