dictionary - trouble with nested try except in python 3.3 -
the problem i'm having if exception thrown first try, seems treat if try statements under except block returned exception.
if player.classname[0] != 'undetermined': if (player.classname[1] != 'undetermined') , (player.classname[2] != 'undetermined'): 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 "+player.classname[0]+"/"+player.classname[1]+"/"+player.classname[2]) print("\tused by: "+player.name+"\t") elif player.classname[1] != 'undetermined': 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 "+player.classname[0]+"/"+player.classname[1]) print("\tused by: "+player.name+"\t") else: in player.abilities: try: overlist[player.classname[0]]['abilities'][i.name].process_ability(i) except: print("ability: "+i.name+" not found in ability index "+player.classname[0]) print("\tused by: "+player.name+"\t")
context: program reads combat logs created game.
player player object contains list called abilities holding abilities used said player, , list classname of size 3 classname[0] string name of player's base class, classname[1] player's subclass , classname[2] player's spec (basically subclass of subclass)
overlist nested dictionary keys names of base classes , values dictionary containing keys subclasses plus key called "abilities" value of dictionary containing abilities specific class. each subclass key has value of dictionary key's each 'spec' of subclass plus "abilities" key associated dictionary of abilities said subclass. each spec key same way it's own 'abilities' key associated dictionary of abilities spec key.
Comments
Post a Comment