【发布时间】:2015-05-05 14:15:05
【问题描述】:
我是 python 语言的新手,我正在尝试理解 self 的概念。
我已经定义了以下两种方法,我想知道必须在代码中进行哪些更改才能将它们包含在一个类中以及在哪里使用self。
import maya.cmds as cmds
# This function returns the animCurves connected to particular node
def animCurveNode():
animCurveName = []
mySel = cmds.ls(sl = True)
filePath = "D:\sdk.txt"
attrName = "l_eyeBrow_Sliders.eyeBrow_start_updn"
for each in mySel:
list = cmds.listConnections(each, d = False,s = True)
animCurveName.extend(list)
return animCurveName
# This function return the animCurves and the name of the atribute to connect as the first memebr in the list
def attrAnimCurve():
attrName = "l_eyeBrow_Sliders.eyeBrow_start_updn"
animCurveNames = animCurveNode()
animCurveNames.insert(0,attrName)
return animCurveNames
【问题讨论】:
-
为什么要在这里使用一个类?了解
self的用途非常重要。
标签: python class methods initialization self