Answer the question
In order to leave comments, you need to log in
How to properly use inheritance in python3?
I have two classes, and one is the parent and the second is the child. When I try to call the parent method, I get an error that the Self argument is missing.
Code example:
class Osnovnoy:
def __init__(self):
self.data = '1100111001010'
def method(self):
return f'{self.data}printuem'
class Rebyonok(Osnovnoy):
def method(self):
print(Osnovnoy.method( ))
class Eto(Master):
def __init__(self):
super().__init__()
def baloonl():
vari = ['Yes', 'No']
ans = random.choice(vari)
requests.post(Master.sendMessage (), data = 'tut something bilo')
class Master:
def __init__(self):
self.link = 'data1'
self.data2 = 'data2'
def sendMessage(self):
send = f'{self.link}/sendMessage'
return send
Answer the question
In order to leave comments, you need to log in
In general, as comrade Nikita Panyukhin noted, I forgot the brackets ...
here is a more correct code example:
class Master:
def __init__(self):
self.link = '0101010'
self.data2 = None
def sendMessage(self):
var = f'{link}/printuem'
return var
class Slave(Master):
def met(self):
vari = ['Yes', 'No']
ans = random.choice(vari)
requests.post(self.sendMessage(), data = ans)
sl = Slave
st.met()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question