From d137ad40b1ba7f88268e0174be2c541fe4d25c44 Mon Sep 17 00:00:00 2001 From: Myned Date: Thu, 19 Oct 2017 04:39:18 -0400 Subject: [PATCH] Compressed try/excepts into a suppressing for loop --- src/main/utils/utils.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/utils/utils.py b/src/main/utils/utils.py index 6bd2fd5..38aa546 100644 --- a/src/main/utils/utils.py +++ b/src/main/utils/utils.py @@ -124,21 +124,16 @@ def get_kwargs(ctx, args, *, limit=False): if '-d' in remaining or '-dm' in remaining: destination = ctx.author - try: - remaining.remove('-d') - except ValueError: - remaining.remove('-dm') + for flag in ('-d', '-dm'): + with suppress(ValueError): + remaining.remove(flag) if ('-r' in remaining or '-rm' in remaining or '-remove' in remaining) and ctx.author.permissions_in(ctx.channel).manage_messages: rm = True - try: - remaining.remove('-r') - except ValueError: - try: - remaining.remove('-rm') - except ValueError: - remaining.remove('-remove') + for flag in ('-r', '-rm', '-remove'): + with suppress(ValueError): + remaining.remove(flag) if limit: for arg in remaining: