php变量 双重命名,函数参数名称中的别名(双重命名)

在Python中,函数的参数是否可以有双重名称?

我的意思是变量名的简短和完整形式。在

我会尽量说清楚的。熟悉Autodesk Maya的每个人都知道

约束的函数。它有一些标志,您可以使用其名称的短格式或长格式:maintainOffset(mo), weight(w), layer(l) and so on..

因此,您可以使用不同的参数名称调用此函数,但结果相同:cmds.parentConstraint(driverObj, drivenObj, maintainOffset=True, weight=1.0,..)

cmds.parentConstraint(driverObj, drivenObj, maintainOffset=True, w=1.0,..)

cmds.parentConstraint(driverObj, drivenObj, mo=True, weight=1.0,..)

cmds.parentConstraint(driverObj, drivenObj, mo=True, w=True,..)

如何在Python中实现这种类型的行为2.7.x?我正在积极使用文档,但仍然找不到答案。在

除此之外,我还为各种类型的约束定义了4个函数:

^{pr2}$

连接列表:cLst = produceConnectionList(tNodesA, tNodesB)

和一些包装器的函数:def batchConnect(type = "parentConstraint", ???):

cLst = produceConnectionList(tNodesA, tNodesB)

if type is "parentConstraint": doParentConstraint(cLst, ???)

if type is "orientConstraint": doOrientConstraint(cLst, ???)

if type is "pointConstraint": doPointConstraint(cLst, ???)

if type is "scaleConstraint": doScaleConstraint(cLst, ???)

但是我不知道如何在这些函数和包装器之间传递值,因为尽管它们有相同数量的参数,但参数的名称和类型稍有不同。在

另外,我想在调用包装器时有机会使用简短和完整的标志名称:batchConnect("pointConstraint", mo=False, offset=(0,0,0), weight=1)

batchConnect("pointConstraint", maintainOffset=False, o=(0,0,0), w=1)

必须这样做。在batchConnect("pointConstraint")

如果没有参数,则必须使用默认值调用doPointConstraint()。在batchConnect()

如果不指定类型和参数,则默认情况下必须使用这些默认值调用doParentConstraint()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值