Python 在类之间共享属性:是多重继承权吗;蟒蛇的;在这里

Python 在类之间共享属性:是多重继承权吗;蟒蛇的;在这里,python,python-3.x,python-2.7,multiple-inheritance,Python,Python 3.x,Python 2.7,Multiple Inheritance,我有一个用例,其中多重继承似乎是正确的方向。但这意味着在“兄弟”类之间共享属性,这些属性是在其他类上初始化的(因此它们不知何故是未知的)。 我想问的是,下面这是一个“正确的”和“pythonic”模型,还是我最好使用一个dertivated类模型 假设我们想要开发不同的交付者,他们将获取一些源数据,对其应用某种格式,并通过某种渠道发送。这三个部分(数据格式发送)可以针对每个案例进行定制 首先,编写代码,使以下示例正常工作: 导入系统 PY3=非系统版本信息

我有一个用例,其中多重继承似乎是正确的方向。但这意味着在“兄弟”类之间共享属性,这些属性是在其他类上初始化的(因此它们不知何故是未知的)。 我想问的是,下面这是一个“正确的”和“pythonic”模型,还是我最好使用一个dertivated类模型

假设我们想要开发不同的交付者,他们将获取一些源数据,对其应用某种格式,并通过某种渠道发送。这三个部分(数据格式发送)可以针对每个案例进行定制

首先,编写代码,使以下示例正常工作:

导入系统 PY3=非系统版本信息<(3,) 从字符串导入模板 导入csv、io、smtplib、请求、操作系统 def read_test_电影(年份从,年份到,类型=无): 测试电影=[ {'year':1971,'release':'01/01/1971,'流派':'thriller','title':'Play Misty for Me', {'year':1973,'release':'02/02/1973,'流派':'浪漫','标题':'微风'}, {'year':1976,'release':'03/03/1976,'流派':'western','title':'theunlaw'}, {'year':1986,'release':'04/04/1986,'流派':'war','title':'Heartbreak'}, {'year':1988,'release':'05/05/1988,'流派':'music','title':'Bird'}, {'year':1992,'release':'06/06/1992,'流派':'western','title':'unforefed'}, {'year':1995,'release':'07/07/1995,'流派':'浪漫','标题':'麦迪逊县的桥梁', {'year':2000,'release':'08/08/2000,'流派':'space','title':'space Cowboys'}, {'year':2003,'release':'09/09/2003,'genre':'trhiller','title':'Mystic River'}, {'year':2004,'release':'10/10/2004,'流派':'体育','头衔':'百万美元宝贝'}, {'year':2006,'release':'11/11/2006,'流派':'war','title':'flagsofourfathers'}, {'year':2006,'release':'12/12/2006,'流派':'战争','标题':'硫磺岛的来信', {'year':2008,'release':'13/11/2008,'流派':'戏剧','标题':'换生灵'}, {'year':2008,'release':'14/10/2008,'流派':'戏剧','标题':'格兰都灵'}, {'year':2009,'release':'15/09/2009,'流派':'sports','title':'Invictus'}, {'year':2010,'release':'16/08/2010,'流派':'戏剧','标题':'此后'}, {'year':2011,'release':'17/07/2011,'流派':'戏剧','标题':'J.埃德加'}, {'year':2014,'release':'18/06/2014,'流派':'战争','头衔':'美国狙击手'}, {'year':2016,'release':'19/05/2016,'流派':'戏剧','标题':'萨利'} ] out=[] 对于测试电影中的m: 如果从
>>> imdbToTxt = TheIMDBToTXTFile(year_from= 2000, year_to= 2010)
>>> imdbToTxt.deliver()
TheIMDBToTXTFile.deliver() => Successfully delivered to /tmp/movies_of_None_from_200_to_2010.txt
>>> 
>>> imdbToWs = TheIMDBToWS(year_from= 2000, year_to= 2010)
>>> imdbToWs.deliver()
TheWSSend.send() Sending to http://spammed.com/movies/send?
TheIMDBToWS.deliver() => Error delivering: 405
>>> 
>>> tmdbToMail = TheTMDbToMail(year_from= 1980, year_to= 2019, genre= 'war')
>>> tmdbToMail.deliver()
TheMailSend.send() Sending to ['movie@spammed.com']
TheTMDbToMail.deliver() => Error delivering: [Errno 111] Connection refused

Instance of 'TheTXTFormat' has no 'genre' member
Instance of 'TheTXTFormat' has no 'year_from' member
Instance of 'TheTXTFormat' has no 'year_to' member
Instance of 'TheTXTFormat' has no 'readMovies' member

Instance of 'TheCSVFormat' has no 'genre' member
Instance of 'TheCSVFormat' has no 'year_from' member
Instance of 'TheCSVFormat' has no 'year_to' member
Instance of 'TheCSVFormat' has no 'readMovies' member

Instance of 'TheMailSend' has no 'make' member
Instance of 'TheWSSend' has no 'make' member