python - Method is being read as attribute? -
I can not use any method in this class Every time I try, I get an error that I do not understand.
walker (cube) c.move () error: There is no feature of 'move' in walker example Here is the code:
Import as pmym.core pm import random class walker (object): def __init __ (auto, cube): self.cube = cube self.tx = 0 self.ty = 0 self .tz = 0 def move (auto): step_dict = {0: move_x, 1: move_y, 2: move_z} step = random.randint (0,2) self.step_dict [step] () def move_x (self): step_dict = {0: 1, 1: -1} step = random.randint (0,1) attr_value = selt.tx + step_dict [step] pm.setAttr ('% s.translateX'% (self.cube), attr_value) self.tx = attr_value def move_y (self): step_dict = {0: 1, 1: -1} step = random.randint (0,1) attr_value = selt.ty + step_dict [a M] Pm.setAttr ('% s.translateY'% (self.cube), attr_value) self.ty = attr_value def move_z (self): step_dict = {0: 1, 1: -1} step = random.randint ( 0, 1) attr_value = selt.tz + step_dict [step] pm.setAttr ('% s.translateZ'% (self.cube), attr_value) self.tz = attr_value c is not an example of
. Try it: type (c) to say it
& lt; class '__main___ walker' & gt;
Comments
Post a Comment