Python - Inheritance -
i'm not understanding online documentation how make inheritance work.
i have here:
import maya.cmds cmds class riglegs(): def __init__(self, *args): self.riglegs() def riglegs(self): self.items["side"] = "left" self.lik = cmds.duplicate(self.ljoints["hip"], n = self.getname("hip_ik")) in self.lik: newname = i[0].replace("_jnt", "_ik") cmds.rename(i, newname)
but it's complaining there no self.items - have inherit class far large post here. can me figure out how that? i've researched online , nothing makes sense.
the other class in different file altogether.
to inherit class do:
class riglegs(base_class_name):
an example:
class base_class(): items = [1,2,3] class pie(base_class): def __init__(self): print (self.items) instance = pie()
you can read more in python documentation
with imports:
file (apples.py)
class base(): items = [1,3,4]
file (main_file.py)
import apples class pie(apples.base): def __init__(self): self.pies() def pies(self): print(self.items) instance = pie()
Comments
Post a Comment