Pylint警告:可能的不平衡元组按顺序拆包

时间:2015-01-16 08:46:44

标签: python tuples pylint packing

我有一段Python代码:

def func1():                                                                                                                  
    a=set()
    b = ','.join(map(str, list(a)))
    return  b, []

def func2():
    d = 1
    e = 2
    return func1() + (d, e,)

def main():
    a,b,c,d = func2()

if __name__ == '__main__':
    main()

当我通过pylint(1.4.0)运行时,我收到警告:

W: 12, 4: Possible unbalanced tuple unpacking with sequence: left side has 4 label(s), right side has 3 value(s) (unbalanced-tuple-unpacking)

似乎func2总会返回四个结果。错误意味着什么?为什么?

1 个答案:

答案 0 :(得分:4)

在出现错误的行后添加# pylint: disable=unbalanced-tuple-unpacking。为我工作