my code in python 2.7Â is:
What I need to know is how to reference a object variable in dictionary in the class of the object. This needs to work on mutable objects. What ever syntax is entered for the dictionary value needs to work when action is called on for another object.
Basically I... need these
sunhear
p.s. sorry if the code tags show
class char(object):    'chactors'     #Create instances of object     def __init__(self,name,d):         self.name = name        self.d = int(d)     def action(self,skill):        for w in char.statlist: #run through statlist dictionary            if skill == w: #refer to the value of the key                print w # check the value of w                 sat = char.statlist[w] #find the value in statlist dictionary.                print sat #check the value of dictionary value                for q in char.satmap:                    if q == sat:                        sat = char.satmap[q]# set sat to char.d ( the value set in statlist)                        print sat                    else:                        pass                     for z in char.skillmap:                        if z == skill:                            skillint = char.skillmap[z] # set skillint to char.mov                            print skillint                        else:                            pass                 t = skillint + sat                 print t #check to see if it ran as exepted            else:                print 'pass'                pass     statlist = {'mov':'d','act':'d'}    skillmap = {'mov':'char.mov'}    satmap = {'d':'char.d'}   char1 = char('q','1') setattr(char1,'mov', 10) setattr(char1,'act', 200)  char1.action('mov')Currently it returns: char.movchar.d However I want it to add the 2 variables together to get 11. char.d/char.mov and self.d/self.mov do not work.Inside the quotes they are treated as string like the current script shows. Outside of  the quotes it gives a name recognition error.
What I need to know is how to reference a object variable in dictionary in the class of the object. This needs to work on mutable objects. What ever syntax is entered for the dictionary value needs to work when action is called on for another object.
Basically I... need these
skillmap = {'mov':'char.mov'} satmap = {'d':'char.d'}to refer to these
def __init__(self,name,d): Â Â Â setattr(char1,'mov', 10)so these values are used
char1 = char('q','1') setattr(char1,'mov', 10)to produce this result
11
sunhear
p.s. sorry if the code tags show