first you have only one dictionary,everything's fine with
def getNPCName(self,ID):
return self.npcs[ID].name
then,got another dictionary,the code become this
def getNPCName(self,ID):
for x in (self.npcs,self.deadnpcs):
if ID in x:
return x[ID].name
return ''
i don't think this would be a good practice.
there should be some dictionary already exists, they union several dictionaries,not really merge them, but act just like one dictionary for some apis.
self.allnpclist = some_kind_of_dictionary(self.alive,self.dead)
my code should be this
def getNPCName(self,ID):
return self.allnpclist[ID].name
i think i shouldn't write it by myself