From e9b8d97a624db0d1d6f7092a7b35d477cb8912eb Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 21 Sep 2019 22:42:40 +1000 Subject: [PATCH] remove unecessary duplication --- post.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/post.py b/post.py index 2221dd6..1c596b5 100644 --- a/post.py +++ b/post.py @@ -24,25 +24,19 @@ except: meta = json.load(open('meta.json', 'r')) takes = json.load(open('takes.json')) -take = random.choice(takes['templates']).format( - ideology = random.choice(takes['ideologies']), - ideology2 = random.choice(takes['ideologies']), - thing = random.choice(takes['things']), - thing2 = random.choice(takes['things']), - thing3 = random.choice(takes['things']), - site = random.choice(takes['sites']), - ideolog = random.choice([i[:-1] + "t" for i in takes['ideologies'] if i.endswith("ism")]) -) +args = { + 'ideology': random.choice(takes['ideologies']), + 'ideology2': random.choice(takes['ideologies']), + 'thing': random.choice(takes['things']), + 'thing2': random.choice(takes['things']), + 'thing3': random.choice(takes['things']), + 'site': random.choice(takes['sites']), + 'ideolog': random.choice([i[:-1] + "t" for i in takes['ideologies'] if i.endswith("ism")]) +} -cw = random.choice(takes['content warnings']).format( - ideology = random.choice(takes['ideologies']), - ideology2 = random.choice(takes['ideologies']), - thing = random.choice(takes['things']), - thing2 = random.choice(takes['things']), - thing3 = random.choice(takes['things']), - site = random.choice(takes['sites']), - ideolog = random.choice([i[:-1] + "t" for i in takes['ideologies'] if i.endswith("ism")]) -) +take = random.choice(takes['templates']).format(**args) + +cw = random.choice(takes['content warnings']).format(**args) print(take)