when I run the code below, I'm constantly hammered by a load of object creation confirmations printing between user inputs... I would love if there was some way I could silence the console while the user focuses on inputting answers. I've found some sketchy solutions, but they seem too convoluted for how simple the issue is. Code snippet and sample output below. Thanks!
Code:
#Engages in battles until user quits
def battle(self):
battles_threshold = min([a.battles_fought for a in self.artists])
contenders = [a for a in self.artists if
a.battles_fought == battles_threshold]
noncontenders = list(set(self.artists)-set(contenders))
print(noncontenders)
contenders.append(random.choice(contenders))
contender1=contenders.pop(random.choice(range(len(contenders))))
contender2=contenders.pop(random.choice(range(len(contenders))))
elo1 = contender1.elo
elo2 = contender2.elo
outcome = ''
while (outcome != 'y' and outcome != 'n' and
outcome != 'm' and outcome != 'q'):
outcome = \
raw_input('Do you like "' + contender1.name +
'" more than "' + contender2.name + '"?\n')
if outcome == 'q':
return None
elif outcome == 'y':
contender1.elo_calc(1,contender2.name,elo2)
contender2.elo_calc(0,contender1.name,elo1)
elif outcome == 'n':
contender1.elo_calc(0,contender2.name,elo2)
contender2.elo_calc(1,contender1.name,elo1)
else:
contender1.elo_calc(0.5,contender2.name,elo2)
contender2.elo_calc(0.5,contender1.name,elo1)
pickle.dump(music_battler, open(self.path_name +
'music_battler.p','wb'))
self.battle()
Output:
Do you like "basshunter" more than "lil wayne"?
y
[<__main__.Artist instance at 0x10dc91ab8>, <__main__.Artist instance at 0x10dc7b050>, <__main__.Artist instance at 0x10dcdb878>, <__main__.Artist instance at 0x10dc82098>, <__main__.Artist instance at 0x10dc830e0>, <__main__.Artist instance at 0x10dc7b908>, <__main__.Artist instance at 0x10da15d88>, <__main__.Artist instance at 0x10dcd1128>, <__main__.Artist instance at 0x10dc7b950>, <__main__.Artist instance at 0x10da0c170>, <__main__.Artist instance at 0x10dccf998>, <__main__.Artist instance at 0x10dc911b8>, <__main__.Artist instance at 0x10dcd89e0>, <__main__.Artist instance at 0x10da1f050>, <__main__.Artist instance at 0x10da0d200>, <__main__.Artist instance at 0x10dc8b1b8>, <__main__.Artist instance at 0x10dab4c68>, <__main__.Artist instance at 0x10dcd1a70>, <__main__.Artist instance at 0x10dcd8290>, <__main__.Artist instance at 0x10dc8b878>, <__main__.Artist instance at 0x10dc9f320>, <__main__.Artist instance at 0x10dcd1dd0>, <__main__.Artist instance at 0x10dc91b00>, <__main__.Artist instance at 0x10dc7b488>, <__main__.Artist instance at 0x10da0d320>, <__main__.Artist instance at 0x10da22b48>, <__main__.Artist instance at 0x10dc85098>, <__main__.Artist instance at 0x10da0bb48>, <__main__.Artist instance at 0x10dcd1c20>, <__main__.Artist instance at 0x10dc7bcb0>, <__main__.Artist instance at 0x10dc85a70>, <__main__.Artist instance at 0x10da1dc68>, <__main__.Artist instance at 0x10dc85e18>, <__main__.Artist instance at 0x10daee488>, <__main__.Artist instance at 0x10dc9fcb0>, <__main__.Artist instance at 0x10dcd14d0>, <__main__.Artist instance at 0x10dc91cf8>, <__main__.Artist instance at 0x10da39d88>, <__main__.Artist instance at 0x10dccfdd0>, <__main__.Artist instance at 0x10dc915f0>, <__main__.Artist instance at 0x10dc91908>, <__main__.Artist instance at 0x10dcddea8>, <__main__.Artist instance at 0x10da2aa70>, <__main__.Artist instance at 0x10dc916c8>, <__main__.Artist instance at 0x10dc85ef0>, <__main__.Artist instance at 0x10dccf710>, <__main__.Artist instance at 0x10dc85758>, <__main__.Artist instance at 0x10da11f80>, <__main__.Artist instance at 0x10dc7bfc8>, <__main__.Artist instance at 0x10dc9f7e8>]
Do you like "alesso" more than "taking back sunday"?