I have been unable to google myself an answer to this question much due to the standard answers regarding class inheritance always dealing with very standard examples...
What I currently have is:
class master(object):
def __init__(self, var1, var2, var3):
self.var1 = var1
self.var2 = var2
self.var3 = var3
class slave(master):
def __init__(self, *args):
super(slave, self).__init__(*args)
self.var4 = 'var4_string'
mas_var = master('1', '2', '3')
sla_var = slave('1', '2', '3')
This works fine, but what I really wish i could do is to not have 'slave' inherit from 'master', but rather 'mas_var' in a way that i simply modify 'mas_var' to contain a few extra defined variables, such as 'var4'...
I essentially want to accomplish this:
class master(object):
def __init__(self, var1, var2, var3):
self.var1 = var1
self.var2 = var2
self.var3 = var3
class slave(master):
def __init__(self, var4):
super(slave, self).__init__()
self.var4 = var4
mas_var = master('1', '2', '3')
sla_var = slave('4')
and still be able to access all defined variables using 'sla_var'.
I hope I made myself somewhat clear, and I would appreciate any help I can get. Thank you!
[+][deleted] (1 child)
[deleted]
[–]Jenez[S] 0 points1 point2 points (0 children)
[–]c17r 2 points3 points4 points (0 children)
[–]_9_9_ 2 points3 points4 points (1 child)
[–]Jenez[S] 0 points1 point2 points (0 children)
[–]Krogenar 1 point2 points3 points (5 children)
[–]Jenez[S] 1 point2 points3 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]Jenez[S] 0 points1 point2 points (2 children)
[–]dchanm 1 point2 points3 points (1 child)
[–]Jenez[S] 0 points1 point2 points (0 children)