If I understood correctly you problem, you could do:
class MCLidarActions( object ):
li = []
tcp_send = 'Event'
def object__updated_changed( self, info ):
print info;
pass;
def _tcp_send_changed( self ):
print( "Click" )
for x in self.li:
x._tcp_send_changed()
class MCUDPActions( MCLidarActions ):
def __init__(self):
self.li.append(self)
def object__updated_changed( self, info ):
pass;
def _tcp_send_changed( self ):
print( "Click UDP" )
class MC_uuuuuuuuuuuuuutp_Actions( MCLidarActions ):
def __init__(self):
self.li.append(self)
def object__updated_changed( self, info ):
pass;
def _tcp_send_changed( self ):
print( "Click _uuuuuuuuuuuuuutp_" )
M = MCLidarActions()
print 'M, instance of MCLidarActions, created ------------'
print ' executing M._tcp_send_changed():'
M._tcp_send_changed()
a = MCUDPActions()
print '\na, instance of MCUDPActions, created ------------'
print ' executing M._tcp_send_changed():'
M._tcp_send_changed()
print
print ' executing a._tcp_send_changed():'
a._tcp_send_changed()
b = MCUDPActions()
print '\nb, instance of MCUDPActions, created ------------'
print ' executing M._tcp_send_changed():'
M._tcp_send_changed()
print
print ' executing a._tcp_send_changed():'
a._tcp_send_changed()
print
print ' executing b._tcp_send_changed():'
b._tcp_send_changed()
v = MC_uuuuuuuuuuuuuutp_Actions()
print '\nv, instance of MC_uuuuuuuuuuuuuutp_Actions, created ------------'
print ' executing M._tcp_send_changed():'
M._tcp_send_changed()
print
print ' executing a._tcp_send_changed():'
a._tcp_send_changed()
print
print ' executing b._tcp_send_changed():'
b._tcp_send_changed()
print
print ' executing v._tcp_send_changed():'
v._tcp_send_changed()
result
M, instance of MCLidarActions, created ------------
executing M._tcp_send_changed():
Click
a, instance of MCUDPActions, created ------------
executing M._tcp_send_changed():
Click
Click UDP
executing a._tcp_send_changed():
Click UDP
b, instance of MCUDPActions, created ------------
executing M._tcp_send_changed():
Click
Click UDP
Click UDP
executing a._tcp_send_changed():
Click UDP
executing b._tcp_send_changed():
Click UDP
v, instance of MC_uuuuuuuuuuuuuutp_Actions, created ------------
executing M._tcp_send_changed():
Click
Click UDP
Click UDP
Click _uuuuuuuuuuuuuutp_
executing a._tcp_send_changed():
Click UDP
executing b._tcp_send_changed():
Click UDP
executing v._tcp_send_changed():
Click _uuuuuuuuuuuuuutp_
But in the above code, it is necessary to define a function __init__ in each subclass MCUDPActions and MC_uuuuuuuuuuuuuutp_Actions of the base class MCLidarActions
To avoid that , the appending in li can be put in the base class:
class MCLidarActions( object ):
li = []
tcp_send = 'Event'
def __init__(self):
if self.__class__ != MCLidarActions:
self.li.append(self)
def object__updated_changed( self, info ):
print info;
pass;
def _tcp_send_changed( self ):
print( "Click" )
for x in self.li:
x._tcp_send_changed()
class MCUDPActions( MCLidarActions ):
def object__updated_changed( self, info ):
pass;
def _tcp_send_changed( self ):
print( "Click UDP" )
class MC_uuuuuuuuuuuuuutp_Actions( MCLidarActions ):
def object__updated_changed( self, info ):
pass;
def _tcp_send_changed( self ):
print( "Click _uuuuuuuuuuuuuutp_" )
and the result is exactly the same.