Python 具有不同参数大小的多重继承

Python 具有不同参数大小的多重继承,python,class,object,Python,Class,Object,我想知道这是否可能。。。目前,我只有一份遗产。。。而且它工作得很好 在我的CiscoPlatform类中,我没有init方法,所以当我使用BasePlatform init方法创建对象时,它需要6个参数 我这样创建对象,效果很好: ntw_device = [] device = CiscoPlatform(list[0],list[1],list[2],list[3],list[4],list[5]) ntw_device.append(device) class BasePlatform(

我想知道这是否可能。。。目前,我只有一份遗产。。。而且它工作得很好

在我的CiscoPlatform类中,我没有init方法,所以当我使用BasePlatform init方法创建对象时,它需要6个参数

我这样创建对象,效果很好:

ntw_device = []
device = CiscoPlatform(list[0],list[1],list[2],list[3],list[4],list[5])
ntw_device.append(device)

class BasePlatform(object):
     def __init__(self,ip,hostname,username,password,vendor,type):
         self.ip = ip
         self.hostname = hostname
         self.username = username
         self.password = password
         self.vendor = vendor
         self.type = type

class Cisco(BasePlatform,Interface):
     pass
我想介绍一个名为Interface的新基类

class Interface(object):
     def __init__(self,host,interface,vlan):
         self.host = host
         self.interface = interface
         self.vlan = vlan
我怎样才能用不同数量的参数继承两个父类?像这样的? *假设switchport=[]-对象列表

class CiscoPlatform(BasePlatform,Interface):
     def __init__(self):
          BaseClass.__init__(self,ntw_device[0].ip,ntw_device[1].hostname,ntw_device[2].username,ntw_device[3].password,ntw_device[4].vendor,ntw_device[5].type)
          Interface.__init__(self,switchport[0].Add to dictionary[1].interface,switchport[2].vlan)
当CiscoPlatform不再接受6个参数时,我如何仍然能够以这种方式再次创建我的对象

device = CiscoPlatform(list[0],list[1],list[2],list[3],list[4],list[5])

我不确定您的目的是否是确保CiscoPlatform类可以接受不同数量的参数,如果是这样的话,就不难了。 当您初始化新的子类时,将调用它的uuu init_uuu来初始化ciscopplatform。因此,您只需要检查传入的参数的数量,然后再决定应该使用哪些基类“\uuu init\uuu”。 类CiscoPlatformBasePlatform,接口: 定义初始自我,*参数: 如果lenarg==6: ip、主机名、用户名、密码、供应商、类型=arg 基类.\uuuu初始化\uuuuu self、ip、主机名、用户名、密码、供应商、类型 elif lenarg==3: 主机,接口,vlan=arg 接口。初始化自身、主机、接口、vlan 其他: raise VALUEMERROR参数数不一致