Vote count:
0
The problem I'm having is that if a exception is thrown for the first try, it seems to treat it as if all try statements under the except block also returned a exception.
if player.ClassName[0] != 'Undetermined':
if (player.ClassName[1] != 'Undetermined') and (player.ClassName[2] != 'Undetermined'):
for i in player.Abilities:
try:
OVERLIST[player.ClassName[0]][player.ClassName[1]][player.ClassName[2]]['Abilities'][i.name].process_ability(i)
except:
try:
OVERLIST[player.ClassName[0]][player.ClassName[1]]['Abilities'][i.name].process_ability(i)
except:
try:
OVERLIST[player.ClassName[0]]['Abilities'][i.name].process_ability(i)
except:
print("Ability: "+i.name+" not found in ability index for "+player.ClassName[0]+"/"+player.ClassName[1]+"/"+player.ClassName[2])
print("\tUsed by: "+player.name+"\t")
elif player.ClassName[1] != 'Undetermined':
for i in player.Abilities:
try:
OVERLIST[player.ClassName[0]][player.ClassName][i.name].process_ability(i)
except:
try:
OVERLIST[player.ClassName[0]]['Abilities'][i.name].process_ability(i)
except:
print("Ability: "+i.name+" not found in ability index for "+player.ClassName[0]+"/"+player.ClassName[1])
print("\tUsed by: "+player.name+"\t")
else:
for i in player.Abilities:
try:
OVERLIST[player.ClassName[0]]['Abilities'][i.name].process_ability(i)
except:
print("Ability: "+i.name+" not found in ability index for "+player.ClassName[0])
print("\tUsed by: "+player.name+"\t")
CONTEXT: This is for a program that reads combat logs created by a game.
player is a Player object that contains a list called Abilities holding all the abilities used by said player, and another list ClassName of size 3 where ClassName[0] is the string name of the player's base class, ClassName[1] is the player's subclass and ClassName[2] is the player's spec (basically subclass of subclass)
OVERLIST is a nested dictionary where the keys are names of the base classes and the values are a dictionary containing keys for the subclasses plus a key called "Abilities" with a value of a dictionary containing the abilities specific to that class. Each subclass key has a value of a dictionary with key's for each 'spec' of the subclass plus a "Abilities" key with associated dictionary of abilities for said subclass. Each spec key is the same way with it's own 'Abilities' key with associated dictionary of abilities for the spec key.
trouble with nested try except in python 3.3
Aucun commentaire:
Enregistrer un commentaire