如何在将元组分配给* args之前解压缩它?

时间:2016-05-22 21:07:40

标签: python oop tuples args

我有以下代码:

    class NumberAdder:
        def adder(self, *args):
            self.sum = 0
            for i in args:
                self.sum += i
            return self.sum

    class StringAdder:
        def adder(self, *args):
            self.word = []
            for i in list(args):
                self.word.append(i)
            print(self.word)

    class ThingsAdder:
        def __init__(self, *args):
            self.box = args
        def stringAdder(self):
            a = StringAdder()
            a.adder(self.box)

        def numberAdder(self):
            a = NumberAdder()
            a.adder(self.box)

    c = ThingsAdder(1,2,3,4,5,6,9)
    c.numberAdder()

问题是你可以看到我将* args分配给另一个* args。我应该怎么做才能使NumberAdder类中的* args接收解压缩(不是以元组的形式)参数?

0 个答案:

没有答案